Tk Source Code

View Ticket
Login
Ticket UUID: 3601604
Title: [listbox $path -takefocus 0] steals focus
Type: Bug Version: current: 8.6.0
Submitter: talvo Created on: 2013-01-21 03:06:32
Subsystem: 09. [listbox] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2015-11-08 22:25:49
Resolution: Fixed Closed By: fvogel
    Closed on: 2015-11-08 22:25:49
Description:
The listbox manpage says it will take focus on <1> if the widget -state is normal and -takefocus is 1. However, it always takes focus, regardless of the -takefocus option.

The binding for <1> on Listbox should be something like

  bind Listbox <1> {    if {[winfo exists %W]} { tk::ListboxBeginSelect %W [%W index @%x,%y] [string is true [%W cget -takefocus]] }}

(Currently, where I have [string is true [%W cget -takefocus]] it just has 1.)
User Comments: fvogel added on 2015-11-08 22:25:49:
Merged in core-8-5-branch and trunk.

fvogel added on 2015-11-06 17:50:43:

I see what you mean.

This has been introduced in [f108de53ea]. Indeed in that commit:

- listbox.n was changed to document that the listbox takes focus only if -takefocus is true.
- listbox.tcl was changed accordingly.

Then this behavior was changed in [a5b8f655a2], but this commit only took care of listbox.tcl and forgot to change back the man page.

I would not fix this problem the way you proposed, for two reasons:

- changing the doc (removing the -takefocus check in the man page) looks better to me since it would not change the widget behavior users know.
- anyway -takefocus is targeted to keyboard traversal (typically using the tab key), and users expected that <1> (i.e. clicking on the listbox) should put the focus on the entry, whatever the keyboard traversal settings are.

Conclusion: let's change the man page, not the code.

Fix along this line is now proposed in branch bug-3601604fff.