diff options
author | fvogel <fvogelnew1@free.fr> | 2020-06-16 22:23:27 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2020-06-16 22:23:27 (GMT) |
commit | 136539153502fe4e2a2bb4f8c3868c457ef8b20b (patch) | |
tree | 947501dbd7a2e86042cfc7b3a36848b1dbc59385 /library | |
parent | 7cc74c617e010821ba81a1f74681f996bc282b6b (diff) | |
download | tk-136539153502fe4e2a2bb4f8c3868c457ef8b20b.zip tk-136539153502fe4e2a2bb4f8c3868c457ef8b20b.tar.gz tk-136539153502fe4e2a2bb4f8c3868c457ef8b20b.tar.bz2 |
Fix [50ed1eddb0]: ttk::spinbox with -values does not loop through all values. The two newly added test cases now pass. Patch from Brad Lanam edited for optimization.
Diffstat (limited to 'library')
-rw-r--r-- | library/ttk/spinbox.tcl | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl index 9728755..6dff302 100644 --- a/library/ttk/spinbox.tcl +++ b/library/ttk/spinbox.tcl @@ -135,13 +135,27 @@ proc ttk::spinbox::Adjust {w v min max} { # -from, -to, and -increment. # proc ttk::spinbox::Spin {w dir} { + variable State + if {[$w instate disabled]} { return } - set nvalues [llength [set values [$w cget -values]]] - set value [$w get] - if {$nvalues} { - set current [lsearch -exact $values $value] - set index [Adjust $w [expr {$current + $dir}] 0 [expr {$nvalues - 1}]] - $w set [lindex $values $index] + + if {![info exists State(values.length)]} { + set State(values.index) -1 + set State(values.last) {} + } + set State(values) [$w cget -values] + set State(values.length) [llength $State(values)] + + if {$State(values.length) > 0} { + set value [$w get] + set current $State(values.index) + if {$value ne $State(values.last)} { + set current [lsearch -exact $State(values) $value] + } + set State(values.index) [Adjust $w [expr {$current + $dir}] 0 \ + [expr {$State(values.length) - 1}]] + set State(values.last) [lindex $State(values) $State(values.index)] + $w set $State(values.last) } else { if {[catch { set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}] |