diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-10 10:17:12 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-10 10:17:12 (GMT) |
commit | 866867dfb7bec2953757d5bf0ca17c930741758c (patch) | |
tree | 65cdf5d944ccf96c77885be06358387b84b2e80e | |
parent | 75bddd3a240d823b5f9fbffb2ebd07413b621223 (diff) | |
download | tk-866867dfb7bec2953757d5bf0ca17c930741758c.zip tk-866867dfb7bec2953757d5bf0ca17c930741758c.tar.gz tk-866867dfb7bec2953757d5bf0ca17c930741758c.tar.bz2 |
Fix [d3cd4c6949]: Make the ttk::notebook::CycleTab proc more robust
-rw-r--r-- | library/ttk/notebook.tcl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl index c5340a5..518c6f5 100644 --- a/library/ttk/notebook.tcl +++ b/library/ttk/notebook.tcl @@ -57,11 +57,13 @@ proc ttk::notebook::Press {w x y} { # Select the next/previous tab in the list. # proc ttk::notebook::CycleTab {w dir} { - if {[$w index end] != 0} { - set current [$w index current] - set select [expr {($current + $dir) % [$w index end]}] - while {[$w tab $select -state] != "normal" && ($select != $current)} { - set select [expr {($select + $dir) % [$w index end]}] + set current [$w index current] + if {$current >= 0} { + set tabCount [$w index end] + set select [expr {($current + $dir) % $tabCount}] + set step [expr {$dir > 0 ? 1 : -1}] + while {[$w tab $select -state] ne "normal" && ($select != $current)} { + set select [expr {($select + $step) % $tabCount}] } if {$select != $current} { ActivateTab $w $select |