Tk Source Code

View Ticket
Login
2016-08-08
21:19 Closed ticket [67c8e8bd71]: DISABLEd Tkinter.Listbox still fires <<ListboxSelect>> for mouse click plus 7 other changes artifact: 1676cc0628 user: fvogel
2016-01-06
20:20 Closed ticket [1288433fff]: LisboxSelect event triggers when listbox state is disabled plus 6 other changes artifact: e86ff7a907 user: fvogel
20:18
Fixed bug [1288433] - LisboxSelect event triggers when listbox state is disabled check-in: 087e635d92 user: fvogel tags: trunk
20:06
Fixed bug [1288433] - LisboxSelect event triggers when listbox state is disabled check-in: b939533336 user: fvogel tags: core-8-5-branch
2015-12-30
22:14 Ticket [1288433fff] LisboxSelect event triggers when listbox state is disabled status still Open with 4 other changes artifact: 8ed306189e user: fvogel
22:07
Fixed bug [1288433] - LisboxSelect event triggers when listbox state is disabled Closed-Leaf check-in: cba57e0967 user: fvogel tags: bug-1288433fff
2015-12-28
18:26 Ticket [1288433fff] LisboxSelect event triggers when listbox state is disabled status still Open with 6 other changes artifact: be8bc57aca user: fvogel
2006-03-13
16:10 Ticket [1288433fff]: 4 changes artifact: c878bdb5a1 user: treincke
2005-09-12
08:22 New ticket [1288433fff]. artifact: b6c01a9a55 user: treincke

Ticket UUID: 1288433
Title: LisboxSelect event triggers when listbox state is disabled
Type: Bug Version: obsolete: 8.4.11
Submitter: treincke Created on: 2005-09-12 08:22:09
Subsystem: 09. [listbox] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-01-06 20:20:27
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-01-06 20:20:27
Description:
This code

   pack [listbox .l] 
   .l insert end 1 2 3 
   bind .l <<ListboxSelect>> {puts click!} 
   .l configure -state disabled

shows that the ListBoxSelect event will be triggered regardless of the state 
of the listbox. Although the listbox is "disabled" so no selection can be 
made, the event fires, indicating a selection has been made.

Jeff Hobbs writes on this subject:

(http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/
b63e43a981b6a698/93341e895ba0c054)

"Hmm, I would cal that a low priority bug.  It appears that the 
ListboxSelect is merely triggering unnecessarily.  The items 
are not actually being selected, so functionally it is all OK, 
but we could avoid the ListboxSelect, so we should."

A workaround on script level is to check for the listbox state in the code for 
the binding:

bind .l <<ListboxSelect>> {
   # abort, if disabled: 
   if {[%W cget -state]=="disabled"} {break} 
   # else do the normal action:
   # ...
}
User Comments: fvogel added on 2016-01-06 20:20:27:
Fix pushed in core-8-5-branch and trunk.

fvogel added on 2015-12-30 22:14:07:
Fix now proposed in branch bug-1288433fff to prevent <<ListboxSelect>> from firing when the listbox is in disabled state.

Precisions on when the <<ListboxSelect>> event fires are added in the listbox documentation.

Corresponding testcase listbox-31.1 added.

treincke added on 2006-03-13 16:10:11:
Logged In: YES 
user_id=370915

I think, to fix the problem, the only changes necessary are 
in the library file 'listbox.tcl' in the procs 

- ::tk::ListboxBeginSelect
- ::tk::ListboxBeginToggle
- ::tk::ListboxMotion

where the line

 if {[$w cget -state]=="disabled"} {return}

should be added at the top of the body. I don't want to 
submit this as patch though, because I have not tested all 
possible cases on all platforms, but on Linux, this fixes 
all troubles and works nicely.