Tk Source Code

View Ticket
Login
Ticket UUID: 7f3bea9f15c21beb7649ec1e8708b23116837cae
Title: ttk::treeview: Button-1 in the indicator area does not select the item
Type: Bug Version: 9.1b1
Submitter: serhiy.storchaka Created on: 2026-09-24 12:00:52
Subsystem: 88. Themed Tk Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-09-30 12:24:35
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-09-30 12:24:35
Description:

Since [ea378fca79] (TIP 740), a Button-1 press on the Treeitem.indicator element only toggles the open state of the item and does not select it.

For leaf items this makes a dead zone: they have no visible indicator, but the space it would occupy is still the indicator element, and a press there does nothing at all. With the default theme this is a 15 pixel wide strip at the left of every leaf row (after the indentation), where clicks are silently ignored:

ttk::treeview .tv -show tree
foreach i {1 2 3} {.tv insert {} end -id I$i -text "Item $i"}
pack .tv; update
set y [expr {[lindex [.tv bbox I2] 1] + 5}]
event generate .tv <Button-1> -x 6 -y $y
event generate .tv <ButtonRelease-1> -x 6 -y $y
.tv selection   ;# I2 in 8.6 and 9.0, empty in 9.1b1

In 9.0 ttk::treeview::Press selected the item and then toggled it. ttk_treeview.n says that <Button-1> "will set the focus (all modes) and selection (all except none select mode) to the item or cell under the mouse pointer".

User Comments: jan.nijtmans added on 2026-09-30 12:24:35:

Merged to [95fb9536b7cf7bf8|trunk], so this ticket can be closed


bohagan added on 2026-09-27 13:14:30:
Yes

serhiy.storchaka added on 2026-09-27 05:48:58:

Thanks. The new test only checks a single click.


bohagan added on 2026-09-26 22:19:46:
Added Double B1 fix and test case in [95fb9536b7cf7bf8]. Testing with the treeview demo shows it works as expected.

serhiy.storchaka added on 2026-09-25 06:42:18:

Thanks, single clicks in the indicator area of a leaf now select the item. DoubleClick still has the same special case: for a leaf it calls ToggleOpenState, which does nothing, so with an ActivateItem handler a double-click in that area does not activate the item. Checking [$w haschildren $item] there too would remove the dead zone completely. A test for both cases would be nice.


bohagan added on 2026-09-25 02:07:56:
Fixed in [2ee8b64bd002e1eb]. I removed the dead-zone for items with no children and hence no open/close indicator. It is intentional that B1 press on the open/close indicator doesn't alter the selection. That's how other toolkits, Windows Explorer, etc. work.