Tk Source Code

View Ticket
Login
Ticket UUID: 368fa4561e6985dd472535b54c3023a51889cc3a
Title: ttk::treeview open/closed indicators can be toggled while hidden
Type: Bug Version: 8.6
Submitter: ulfalizer Created on: 2019-04-07 12:57:56
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-04-19 09:16:58
Resolution: Fixed Closed By: fvogel
    Closed on: 2019-04-19 09:16:58
Description: (text/html)
Try the following example, and notice that the tree open/closed status is toggled by clicking on the non-existent (or maybe just hidden) open/closed indicator.

<pre>
pack [ttk::treeview .tree] -fill x
bind .tree <1> {puts [.tree identify element %x %y]}
.tree insert {} end -id foo -text "<-- (1) Click the blank space to my left" 

pack [ttk::button .button -text "(2) Click here and notice that the subtree starts out open" \
      -command {.tree insert foo end -text "sub"}]
</pre>

Another thing that might be minorly confusing is that the identify call returns "TreeItem.indicator" when clicking where the indicator would be. Might be intentional though.
<br><br>
It's great that items remember their open/closed status when being detached and reattached by the way. My GUI relies heavily on it, because it dynamically updates the tree a lot. :)
User Comments: fvogel added on 2019-04-19 09:16:58:
Merged to core-8-6-branch and trunk.

fvogel added on 2019-04-13 16:46:11:
I have added test treeview-368fa4561e checking for non-regression regarding this bug.

fvogel added on 2019-04-13 07:35:21:
Wait a second, I'll close this ticket when I merge the fix. Besides, I'm still thinking at whether the fix can be tested and if a new test could be added or not. Reopening for the moment.

ulfalizer added on 2019-04-11 00:18:13:
> About the string returned by "identify", I didn't change anything. What other
> output than "TreeItem.indicator" would you expect? Documentation says this
> "identify" command identifies the "element" (which has to be undertood as: the
> element of the layout, as described in the ttk::intro man page) on which the user
> clicked. This remains true whether the indicator is visible or not: this portion
> of the screen is the room allocated for the indicator.

Makes sense. Wanted to make sure the element was supposed to be considered "there" while hidden.

Tried out the fix - works fine. Thanks!

fvogel added on 2019-04-10 20:02:17: (text/x-fossil-wiki)
I have a fix, please see [f8bab95d] in the dedicated bugfix branch [https://core.tcl-lang.org/tk/timeline?r=bug-368fa4561e|bug-368fa4561e].

This fix prevents toggling on tree leafs, which do not show indicators. Please test with your application.

About the string returned by "identify", I didn't change anything. What other output than "TreeItem.indicator" would you expect? Documentation says this "identify" command identifies the "element" (which has to be undertood as: the element of the layout, as described in the [https://www.tcl.tk/man/tcl/TkCmd/ttk_intro.htm|ttk::intro man page]) on which the user clicked. This remains true whether the indicator is visible or not: this portion of the screen is the room allocated for the indicator.