diff options
Diffstat (limited to 'library/menu.tcl')
-rw-r--r-- | library/menu.tcl | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index 4ce0d8c..cc57532 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -259,8 +259,10 @@ proc ::tk::MbPost {w {x {}} {y {}}} { if {$cur ne ""} { MenuUnpost {} } - set Priv(cursor) [$w cget -cursor] - $w configure -cursor arrow + if {$::tk_strictMotif} { + set Priv(cursor) [$w cget -cursor] + $w configure -cursor arrow + } if {[tk windowingsystem] ne "aqua"} { set Priv(relief) [$w cget -relief] $w configure -relief raised @@ -402,12 +404,19 @@ proc ::tk::MenuUnpost menu { # Unpost menu(s) and restore some stuff that's dependent on # what was posted. + after cancel [array get Priv menuActivatedTimer] + unset -nocomplain Priv(menuActivated) + after cancel [array get Priv menuDeactivatedTimer] + unset -nocomplain Priv(menuDeactivated) + catch { if {$mb ne ""} { set menu [$mb cget -menu] $menu unpost set Priv(postedMb) {} - $mb configure -cursor $Priv(cursor) + if {$::tk_strictMotif} { + $mb configure -cursor $Priv(cursor) + } if {[tk windowingsystem] ne "aqua"} { $mb configure -relief $Priv(relief) } else { @@ -453,7 +462,9 @@ proc ::tk::MenuUnpost menu { } RestoreOldGrab if {$Priv(menuBar) ne ""} { - $Priv(menuBar) configure -cursor $Priv(cursor) + if {$::tk_strictMotif} { + $Priv(menuBar) configure -cursor $Priv(cursor) + } set Priv(menuBar) {} } if {[tk windowingsystem] ne "x11"} { @@ -537,6 +548,7 @@ proc ::tk::MbButtonUp w { proc ::tk::MenuMotion {menu x y state} { variable ::tk::Priv if {$menu eq $Priv(window)} { + set activeindex [$menu index active] if {[$menu cget -type] eq "menubar"} { if {[info exists Priv(focus)] && $menu ne $Priv(focus)} { $menu activate @$x,$y @@ -546,9 +558,22 @@ proc ::tk::MenuMotion {menu x y state} { $menu activate @$x,$y GenerateMenuSelect $menu } - } - if {($state & 0x1f00) != 0} { - $menu postcascade active + set index [$menu index @$x,$y] + if {[info exists Priv(menuActivated)] \ + && $index ne "none" \ + && $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}] + if {[$menu type $index] eq "cascade"} { + set Priv(menuActivatedTimer) \ + [after $delay [list $menu postcascade active]] + } else { + set Priv(menuDeactivatedTimer) \ + [after $delay [list $menu postcascade none]] + } + } + } } } @@ -586,8 +611,13 @@ proc ::tk::MenuButtonDown menu { if {$Priv(menuBar) eq {}} { set Priv(menuBar) $menu - set Priv(cursor) [$menu cget -cursor] - $menu configure -cursor arrow + if {$::tk_strictMotif} { + set Priv(cursor) [$menu cget -cursor] + $menu configure -cursor arrow + } + if {[$menu type active] eq "cascade"} { + set Priv(menuActivated) 1 + } } # Don't update grab information if the grab window isn't changing. @@ -1307,6 +1337,7 @@ proc ::tk_popup {menu x y {entry {}}} { tk::SaveGrabInfo $menu grab -global $menu set Priv(popup) $menu + set Priv(menuActivated) 1 tk_menuSetFocus $menu } } |