Author: Donal Fellows <[email protected]>
State: Final
Type: Project
Vote: Done
Created: 07-Sep-2023
Tcl-Version: 9.0
Keywords: Tk, Ttk
Tk-Branch: treeview-list-detached
Abstract
This TIP proposes a method for treeview widgets for better working with detached items.
Rationale
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.
Specification
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:
widget detached
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.
Copyright
This document has been placed in the public domain.