Tk Library Source Code

Artifact [853cd6ee99]
Login

Artifact 853cd6ee99198ec72a3b6e9350b2c896b10a7016:

Attachment "combobox.tcl.patch" to ticket [1588808fff] added by daiei27 2006-11-02 02:17:25.
--- combobox_original.tcl	2006-11-01 13:45:26.000000000 -0500
+++ combobox.tcl	2006-11-01 13:45:36.000000000 -0500
@@ -181,8 +181,8 @@
     set entry $path.e
 
 
-    set list [list -images -values -bwlistbox -hottrack]
-    foreach {ci cv cb ch} [eval [linsert $list 0 Widget::hasChangedX $path]] { break }
+    set list [list -images -values -bwlistbox -hottrack -autocomplete -autopost]
+    foreach {ci cv cb ch cac cap} [eval [linsert $list 0 Widget::hasChangedX $path]] { break }
 
     if { $ci } {
         set images [Widget::cget $path -images]
@@ -193,6 +193,40 @@
         }
     }
 
+    ## If autocomplete toggled, turn bindings on/off
+    if { $cac } {
+        if {[Widget::cget $path -autocomplete]} {
+            ::bind $entry <KeyRelease> +[list $path _auto_complete %K]
+        } else {
+            set bindings [split [::bind $entry <KeyRelease>] \n]
+            if {[set idx [lsearch $bindings [list $path _auto_complete %K]]] != -1} {
+                ::bind $entry <KeyRelease> [join [lreplace $bindings $idx $idx] \n]
+            }
+        }
+    }
+
+    ## If autopost toggled, turn bindings on/off
+    if { $cap } {
+        if {[Widget::cget $path -autopost]} {
+            ::bind $entry <KeyRelease> +[list $path _auto_post %K]
+            set bindings [split [::bind $entry <Key-Up>] \n]
+            if {[set idx [lsearch $bindings [list ComboBox::_unmapliste $path]]] != -1} {
+                ::bind $entry <Key-Up> [join [lreplace $bindings $idx $idx] \n]
+            }
+            set bindings [split [::bind $entry <Key-Down>] \n]
+            if {[set idx [lsearch $bindings [list ComboBox::_mapliste $path]]] != -1} {
+                ::bind $entry <Key-Down> [join [lreplace $bindings $idx $idx] \n]
+            }
+        } else {
+            set bindings [split [::bind $entry <KeyRelease>] \n]
+            if {[set idx [lsearch $bindings [list $path _auto_post %K]]] != -1} {
+                ::bind $entry <KeyRelease> [join [lreplace $bindings $idx $idx] \n]
+            }
+            ::bind $entry <Key-Up> +[list ComboBox::_unmapliste $path]
+            ::bind $entry <Key-Down> +[list ComboBox::_mapliste $path]
+        }
+    }
+
     set bw [Widget::cget $path -bwlistbox]
 
     ## If the images, bwlistbox, hottrack or values have changed,