diff options
-rw-r--r-- | library/ttk/treeview.tcl | 6 | ||||
-rw-r--r-- | tests/ttk/treeview.test | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 1ed87db..6a6f5d4 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -336,6 +336,12 @@ proc ttk::treeview::CloseItem {w item} { ## Toggle -- toggle opened/closed state of item # proc ttk::treeview::Toggle {w item} { + # don't allow toggling on indicators that + # are not present in front of leaf items + if {[$w children $item] == {}} { + return + } + # not a leaf, toggle! if {[$w item $item -open]} { CloseItem $w $item } else { diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index aa7e64a..be82f68 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -636,4 +636,21 @@ test treeview-3085489-2 "tag remove, no -tags" -setup { destroy .tv } -result [list] +test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { + pack [ttk::treeview .tv] + .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left" + update +} -body { + foreach {x y w h} [.tv bbox foo #0] {} + set res [.tv item foo -open] + # using $h even for x computation is intentional here in order to simulate + # a mouse click on the (invisible since we're on a leaf) indicator + event generate .tv <ButtonPress-1> \ + -x [expr ($x + $h / 2)] \ + -y [expr ($y + $h / 2)] + lappend res [.tv item foo -open] + .tv insert foo end -text "sub" + lappend res [.tv item foo -open] +} -result {0 0 0} + tcltest::cleanupTests |