summaryrefslogtreecommitdiffstats
path: root/library/listbox.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/listbox.tcl')
-rw-r--r--library/listbox.tcl13
1 files changed, 9 insertions, 4 deletions
diff --git a/library/listbox.tcl b/library/listbox.tcl
index 9fd86e4..f3434a5 100644
--- a/library/listbox.tcl
+++ b/library/listbox.tcl
@@ -33,7 +33,7 @@
bind Listbox <1> {
if {[winfo exists %W]} {
- tk::ListboxBeginSelect %W [%W index @%x,%y]
+ tk::ListboxBeginSelect %W [%W index @%x,%y] 1
}
}
@@ -176,7 +176,8 @@ bind Listbox <B2-Motion> {
# The MouseWheel will typically only fire on Windows and Mac OS X.
# However, someone could use the "event generate" command to produce
# one on other platforms.
-if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} {
+
+if {[tk windowingsystem] eq "aqua"} {
bind Listbox <MouseWheel> {
%W yview scroll [expr {- (%D)}] units
}
@@ -224,7 +225,7 @@ if {"x11" eq [tk windowingsystem]} {
# el - The element for the selection operation (typically the
# one under the pointer). Must be in numerical form.
-proc ::tk::ListboxBeginSelect {w el} {
+proc ::tk::ListboxBeginSelect {w el {focus 1}} {
variable ::tk::Priv
if {[$w cget -selectmode] eq "multiple"} {
if {[$w selection includes $el]} {
@@ -240,6 +241,10 @@ proc ::tk::ListboxBeginSelect {w el} {
set Priv(listboxPrev) $el
}
event generate $w <<ListboxSelect>>
+ # check existence as ListboxSelect may destroy us
+ if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} {
+ focus $w
+ }
}
# ::tk::ListboxMotion --
@@ -477,7 +482,7 @@ proc ::tk::ListboxCancel w {
}
set first [$w index anchor]
set last $Priv(listboxPrev)
- if { $last eq "" } {
+ if {$last eq ""} {
# Not actually doing any selection right now
return
}