Author: Donal Fellows <[email protected]> State: Draft Type: Project Vote: Pending Created: 07-Sep-2023 Tcl-Version: 9.0 Keywords: Tk, Ttk Tk-Branch: treeview-list-detached
This TIP proposes a method for treeview widgets for better working with detached items.
One of the features of the treeview is that it allows an item to be detached and then reattached elsewhere, providing a means where chunks of the tree can be moved around cheaply. However, as this Stack Overflow question hints at, if you lose the IDs of the detached items, there's no way to get them back. This is at odds with Tk's general principles of discoverability.
This TIP proposes a new subcommand for treeview widgets, detached, for discovering detached items and querying the detached status of an item. It can be used in two ways:
Returns a list of all detached items of the treeview widget in an arbitrary order. (The implementation uses the natural iteration order of the internal hash table mapping from item names to item records.)
widget detached item
Returns a boolean value that is true when the given item is detached.
Items are considered to be detached when they have no parent or siblings and are not the root item. (Note that the root item cannot be detached; this is enforced by existing code.) Items with a detached parent are not themselves considered to be detached.
This document has been placed in the public domain.