diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-12-12 13:03:30 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-12-12 13:03:30 (GMT) |
commit | 41c09d4eae90dcdf6a7e1e4a026ba320356e500a (patch) | |
tree | b9ed29964c2c941274ff53c67944b24a8f5f7c2a /library/menu.tcl | |
parent | e76d34cdf6a82f06d8340580557e203f3b3086ef (diff) | |
download | tk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.zip tk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.tar.gz tk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.tar.bz2 |
Backport some clean-up from 8.7
Diffstat (limited to 'library/menu.tcl')
-rw-r--r-- | library/menu.tcl | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index deca485..3de7cc5 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -88,7 +88,7 @@ bind Menubutton <Enter> { bind Menubutton <Leave> { tk::MbLeave %W } -bind Menubutton <1> { +bind Menubutton <Button-1> { if {$tk::Priv(inMenubutton) ne ""} { tk::MbPost $tk::Priv(inMenubutton) %X %Y } @@ -475,7 +475,7 @@ proc ::tk::MbButtonUp w { proc ::tk::MenuMotion {menu x y state} { variable ::tk::Priv if {$menu eq $Priv(window)} { - set active [$menu index active] + set activeindex [$menu index active] if {[$menu cget -type] eq "menubar"} { if {[info exists Priv(focus)] && $menu ne $Priv(focus)} { $menu activate @$x,$y @@ -488,7 +488,7 @@ proc ::tk::MenuMotion {menu x y state} { set index [$menu index @$x,$y] if {[info exists Priv(menuActivated)] \ && $index ne "none" \ - && $index ne $active} { + && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] if {[string is false $mode]} { set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] @@ -496,10 +496,12 @@ proc ::tk::MenuMotion {menu x y state} { # Catch these postcascade commands since the menu could be # destroyed before they run. set Priv(menuActivatedTimer) \ - [after $delay "catch {$menu postcascade active}"] + [after $delay [list catch [list \ + $menu postcascade active]]] } else { set Priv(menuDeactivatedTimer) \ - [after $delay "catch {$menu postcascade none}"] + [after $delay [list catch [list + $menu postcascade {}]]] } } } @@ -819,10 +821,11 @@ proc ::tk::MenuNextMenu {menu direction} { # -1 means go to the next higher entry. proc ::tk::MenuNextEntry {menu count} { - if {[$menu index last] eq "none"} { + set last [$menu index last] + if {$last eq "none"} { return } - set length [expr {[$menu index last]+1}] + set length [expr {$last+1}] set quitAfter $length set active [$menu index active] if {$active eq "none"} { @@ -903,13 +906,12 @@ proc ::tk::MenuFind {w char} { } set last [$child index last] for {set i [$child cget -tearoff]} {$i <= $last} {incr i} { - if {[$child type $i] eq "separator"} { + if {([$child type $i] eq "separator") || ([$child entrycget $i -state] eq "disabled")} { continue } - set char2 [string index [$child entrycget $i -label] \ - [$child entrycget $i -underline]] - if {$char eq [string tolower $char2] || $char eq ""} { - if {[$child entrycget $i -state] ne "disabled"} { + set underline [$child entrycget $i -underline] + if {$underline >= 0} { + if {$char eq [string tolower [string index [$child entrycget $i -label] $underline]]} { return $child } } @@ -941,7 +943,7 @@ proc ::tk::MenuFind {w char} { } } } - return "" + return {} } # ::tk::TraverseToMenu -- |