summaryrefslogtreecommitdiffstats
path: root/library/ttk/combobox.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/ttk/combobox.tcl')
-rw-r--r--library/ttk/combobox.tcl56
1 files changed, 35 insertions, 21 deletions
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl
index 6f34f69..f04aaaa 100644
--- a/library/ttk/combobox.tcl
+++ b/library/ttk/combobox.tcl
@@ -1,13 +1,8 @@
#
-# $Id: combobox.tcl,v 1.12.2.3 2010/01/20 23:43:51 patthoyts Exp $
+# $Id: combobox.tcl,v 1.12.2.4 2010/08/26 02:06:10 hobbs Exp $
#
# Combobox bindings.
#
-# Each combobox $cb has a child $cb.popdown, which contains
-# a listbox $cb.popdown.l and a scrollbar. The listbox -listvariable
-# is set to a namespace variable, which is used to synchronize the
-# combobox values with the listbox values.
-#
# <<NOTE-WM-TRANSIENT>>:
#
# Need to set [wm transient] just before mapping the popdown
@@ -60,12 +55,9 @@ bind TCombobox <Shift-ButtonPress-1> { ttk::combobox::Press "s" %W %x %y }
bind TCombobox <Double-ButtonPress-1> { ttk::combobox::Press "2" %W %x %y }
bind TCombobox <Triple-ButtonPress-1> { ttk::combobox::Press "3" %W %x %y }
bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x }
+bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y }
-bind TCombobox <MouseWheel> { ttk::combobox::Scroll %W [expr {%D/-120}] }
-if {[tk windowingsystem] eq "x11"} {
- bind TCombobox <ButtonPress-4> { ttk::combobox::Scroll %W -1 }
- bind TCombobox <ButtonPress-5> { ttk::combobox::Scroll %W 1 }
-}
+ttk::bindMouseWheel TCombobox [list ttk::combobox::Scroll %W]
bind TCombobox <<TraverseIn>> { ttk::combobox::TraverseIn %W }
@@ -152,6 +144,19 @@ proc ttk::combobox::Drag {w x} {
}
}
+## Motion --
+# Set cursor.
+#
+proc ttk::combobox::Motion {w x y} {
+ if { [$w identify $x $y] eq "textarea"
+ && [$w instate {!readonly !disabled}]
+ } {
+ ttk::setCursor $w text
+ } else {
+ ttk::setCursor $w ""
+ }
+}
+
## TraverseIn -- receive focus due to keyboard navigation
# For editable comboboxes, set the selection and insert cursor.
#
@@ -216,9 +221,9 @@ proc ttk::combobox::LBTab {lb dir} {
LBSelect $lb
Unpost $cb
# The [grab release] call in [Unpost] queues events that later
- # re-set the focus. [update] to make sure these get processed first:
- update
- ttk::traverseTo $newFocus
+ # re-set the focus (@@@ NOTE: this might not be true anymore).
+ # Set new focus later:
+ after 0 [list ttk::traverseTo $newFocus]
}
}
@@ -265,7 +270,8 @@ proc ttk::combobox::PopdownWindow {cb} {
variable scrollbar
if {![winfo exists $cb.popdown]} {
- set popdown [PopdownToplevel $cb.popdown]
+ set poplevel [PopdownToplevel $cb.popdown]
+ set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame]
$scrollbar $popdown.sb \
-orient vertical -command [list $popdown.l yview]
@@ -280,9 +286,14 @@ proc ttk::combobox::PopdownWindow {cb} {
bindtags $popdown.l \
[list $popdown.l ComboboxListbox Listbox $popdown all]
- grid $popdown.l $popdown.sb -sticky news
+ grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew
+ grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns
grid columnconfigure $popdown 0 -weight 1
grid rowconfigure $popdown 0 -weight 1
+
+ grid $popdown -sticky news -padx 0 -pady 0
+ grid rowconfigure $poplevel 0 -weight 1
+ grid columnconfigure $poplevel 0 -weight 1
}
return $cb.popdown
}
@@ -297,13 +308,14 @@ proc ttk::combobox::PopdownToplevel {w} {
switch -- [tk windowingsystem] {
default -
x11 {
- $w configure -relief solid -borderwidth 1
+ $w configure -relief flat -borderwidth 0
wm attributes $w -type combo
wm overrideredirect $w true
}
win32 {
- $w configure -relief solid -borderwidth 1
+ $w configure -relief flat -borderwidth 0
wm overrideredirect $w true
+ wm attributes $w -topmost 1
}
aqua {
$w configure -relief solid -borderwidth 0
@@ -322,7 +334,7 @@ proc ttk::combobox::PopdownToplevel {w} {
proc ttk::combobox::ConfigureListbox {cb} {
variable Values
- set popdown [PopdownWindow $cb]
+ set popdown [PopdownWindow $cb].f
set values [$cb cget -values]
set current [$cb current]
if {$current < 0} {
@@ -337,8 +349,10 @@ proc ttk::combobox::ConfigureListbox {cb} {
if {$height > [$cb cget -height]} {
set height [$cb cget -height]
grid $popdown.sb
+ grid configure $popdown.l -padx {1 0}
} else {
grid remove $popdown.sb
+ grid configure $popdown.l -padx 1
}
$popdown.l configure -height $height
}
@@ -383,7 +397,7 @@ proc ttk::combobox::Post {cb} {
set popdown [PopdownWindow $cb]
ConfigureListbox $cb
- update idletasks
+ update idletasks ;# needed for geometry propagation.
PlacePopdown $cb $popdown
# See <<NOTE-WM-TRANSIENT>>
switch -- [tk windowingsystem] {
@@ -411,7 +425,7 @@ proc ttk::combobox::Unpost {cb} {
# Return the combobox main widget that owns the listbox.
#
proc ttk::combobox::LBMaster {lb} {
- winfo parent [winfo parent $lb]
+ winfo parent [winfo parent [winfo parent $lb]]
}
## LBSelect $lb --