diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-01-01 23:37:20 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-01-01 23:37:20 (GMT) |
commit | 5b17775ceec76475fc09958fe95ea3463bf0d4a0 (patch) | |
tree | 59b2e125921d7d2cb4ffa29ae6ab5ef7b39dec8b /library/menu.tcl | |
parent | e89506924ebc59f7c9bcf77f749d62f59893105e (diff) | |
download | tk-5b17775ceec76475fc09958fe95ea3463bf0d4a0.zip tk-5b17775ceec76475fc09958fe95ea3463bf0d4a0.tar.gz tk-5b17775ceec76475fc09958fe95ea3463bf0d4a0.tar.bz2 |
Keep menu.tcl/tearoff.tcl more in sync with 8.7
Diffstat (limited to 'library/menu.tcl')
-rw-r--r-- | library/menu.tcl | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index c334fd9..1fb6e78 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -488,6 +488,7 @@ proc ::tk::MenuMotion {menu x y state} { set index [$menu index @$x,$y] if {[info exists Priv(menuActivated)] \ && $index ne "none" \ + && $index >= 0 \ && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] if {[string is false $mode]} { @@ -529,7 +530,8 @@ proc ::tk::MenuButtonDown menu { if {![winfo viewable $menu]} { return } - if {[$menu index active] eq "none"} { + set activeindex [$menu index active] + if {($activeindex eq "none") || ($activeindex < 0)} { if {[$menu cget -type] ne "menubar" } { set Priv(window) {} } @@ -587,7 +589,8 @@ proc ::tk::MenuButtonDown menu { proc ::tk::MenuLeave {menu rootx rooty state} { variable ::tk::Priv set Priv(window) {} - if {[$menu index active] eq "none"} { + set activeindex [$menu index active] + if {($activeindex eq "none") || ($activeindex < 0)} { return } if {[$menu type active] eq "cascade" \ @@ -632,8 +635,8 @@ proc ::tk::MenuInvoke {w buttonRelease} { MenuUnpost $w } elseif {[$w cget -type] eq "menubar"} { $w postcascade none - set active [$w index active] - set isCascade [string equal [$w type $active] "cascade"] + set activeindex [$w index active] + set isCascade [string equal [$w type $activeindex] "cascade"] # Only de-activate the active item if it's a cascade; this prevents # the annoying "activation flicker" you otherwise get with @@ -651,11 +654,11 @@ proc ::tk::MenuInvoke {w buttonRelease} { # but not recommended) if { !$isCascade } { - uplevel #0 [list $w invoke $active] + uplevel #0 [list $w invoke $activeindex] } } else { - set active [$w index active] - if {$Priv(popup) eq "" || $active ne "none"} { + set activeindex [$w index active] + if {$Priv(popup) eq "" || (($activeindex ne "none") && ($activeindex >= 0)} { MenuUnpost $w } uplevel #0 [list $w invoke active] @@ -799,7 +802,8 @@ proc ::tk::MenuNextMenu {menu direction} { if {[winfo class $mb] eq "Menubutton" \ && [$mb cget -state] ne "disabled" \ && [$mb cget -menu] ne "" \ - && [[$mb cget -menu] index last] ne "none"} { + && [[$mb cget -menu] index last] ne "none" \ + && [[$mb cget -menu] index last] >= 0} { break } if {$mb eq $w} { @@ -822,16 +826,16 @@ proc ::tk::MenuNextMenu {menu direction} { proc ::tk::MenuNextEntry {menu count} { set last [$menu index last] - if {$last eq "none"} { + if {($last eq "none") || ($last < 0)} { return } set length [expr {$last+1}] set quitAfter $length - set active [$menu index active] - if {$active eq "none"} { + set activeindex [$menu index active] + if {($activeindex eq "none") || ($activeindex < 0)} { set i 0 } else { - set i [expr {$active + $count}] + set i [expr {$activeindex + $count}] } while {1} { if {$quitAfter <= 0} { @@ -853,7 +857,7 @@ proc ::tk::MenuNextEntry {menu count} { break } } - if {$i == $active} { + if {$i == $activeindex} { return } incr i $count @@ -1070,7 +1074,8 @@ proc ::tk::MenuFirstEntry menu { return } tk_menuSetFocus $menu - if {[$menu index active] ne "none"} { + set activeindex [$menu index active] + if {($activeindex ne "none") && ($activeindex >= 0)} { return } set last [$menu index last] |