From 4f503e1d1c1ba2e564bf26b58a23c3caf2c411ea Mon Sep 17 00:00:00 2001 From: patthoyts Date: Sat, 30 Apr 2011 22:28:14 +0000 Subject: [Bug 2949774]: cascade menus should popdown ofter loosing the pointer. When the pointer moves to another entry from a cascade entry the sub-menu should popdown. This is how other menus on X11 work today. This effect will not be used if the user has configured ClickToFocus to maintain the previous Tk menu effects. (backported from trunk) Signed-off-by: Pat Thoyts --- library/menu.tcl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/library/menu.tcl b/library/menu.tcl index bf5c955..e415ce0 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -408,6 +408,8 @@ proc ::tk::MenuUnpost menu { after cancel [array get Priv menuActivatedTimer] unset -nocomplain Priv(menuActivated) + after cancel [array get Priv menuDeactivatedTimer] + unset -nocomplain Priv(menuDeactivated) catch { if {$mb ne ""} { @@ -563,13 +565,18 @@ proc ::tk::MenuMotion {menu x y state} { set index [$menu index @$x,$y] if {[info exists Priv(menuActivated)] \ && $index ne "none" \ - && $index ne $activeindex \ - && [$menu type $index] eq "cascade"} { + && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] if {$mode eq "" || ([string is boolean $mode] && !$mode)} { - set delay [expr {[$menu cget -type] eq "menubar"? 0 : 50}] - set Priv(menuActivatedTimer) \ - [after $delay [list $menu postcascade active]] + set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] + if {[$menu type $activeindex] eq "cascade"} { + set Priv(menuDeactivatedTimer) \ + [after $delay [list $menu postcascade none]] + } + if {[$menu type $index] eq "cascade"} { + set Priv(menuActivatedTimer) \ + [after $delay [list $menu postcascade active]] + } } } } -- cgit v0.12 From 8bd5cf46f53712c5c4ee5dd8f1cfbbf761075bb0 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Sat, 30 Apr 2011 22:29:49 +0000 Subject: [Bug 3294593] fix menu unposting under some conditions. Moving the pointer off a cascaded submenu over the application window and then back to the parent menu window on a non-cascade entry would leave the submenu displayed when it should be unposted. This patch solves this issue. Suggested-by: Schelte Bron Signed-off-by: Pat Thoyts --- library/menu.tcl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/menu.tcl b/library/menu.tcl index e415ce0..31da4fb 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -567,15 +567,14 @@ proc ::tk::MenuMotion {menu x y state} { && $index ne "none" \ && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] - if {$mode eq "" || ([string is boolean $mode] && !$mode)} { + if {[string is false $mode]} { set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] - if {[$menu type $activeindex] eq "cascade"} { - set Priv(menuDeactivatedTimer) \ - [after $delay [list $menu postcascade none]] - } 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]] } } } -- cgit v0.12 From 04526fe293b1b59c39461441d8c3ac06218ad187 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Wed, 1 Jun 2011 10:47:49 +0000 Subject: [Bug # 3306909]: tk_popup placement on Windows Vista can be incorrect. When posting menus near the bottom of the screen on Windows versions newer than XP the menu may be placed incorrectly. This is due to code in PostOverPoint that corrects an error in the XP window manager. This fix is no longer required for Vista and Windows7. Reported-by: Harald Oehlmann Signed-off-by: Pat Thoyts --- library/menu.tcl | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/library/menu.tcl b/library/menu.tcl index 31da4fb..f66c498 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -1224,24 +1224,35 @@ proc ::tk::PostOverPoint {menu x y {entry {}}} { } incr x [expr {-[winfo reqwidth $menu]/2}] } - if {$tcl_platform(platform) == "windows"} { + + if {$tcl_platform(platform) eq "windows"} { + # osVersion is not available in safe interps + set ver 5 + if {[info exists tcl_platform(osVersion)]} { + scan $tcl_platform(osVersion) %d ver + } + # We need to fix some problems with menu posting on Windows, # where, if the menu would overlap top or bottom of screen, # Windows puts it in the wrong place for us. We must also # subtract an extra amount for half the height of the current # entry. To be safe we subtract an extra 10. - set yoffset [expr {[winfo screenheight $menu] \ - - $y - [winfo reqheight $menu] - 10}] - if {$yoffset < 0} { - # The bottom of the menu is offscreen, so adjust upwards - incr y $yoffset - if {$y < 0} { set y 0 } - } - # If we're off the top of the screen (either because we were - # originally or because we just adjusted too far upwards), - # then make the menu popup on the top edge. - if {$y < 0} { - set y 0 + # NOTE: this issue appears to have been resolved in the Window + # manager provided with Vista and Windows 7. + if {$ver < 6} { + set yoffset [expr {[winfo screenheight $menu] \ + - $y - [winfo reqheight $menu] - 10}] + if {$yoffset < 0} { + # The bottom of the menu is offscreen, so adjust upwards + incr y $yoffset + if {$y < 0} { set y 0 } + } + # If we're off the top of the screen (either because we were + # originally or because we just adjusted too far upwards), + # then make the menu popup on the top edge. + if {$y < 0} { + set y 0 + } } } $menu post $x $y -- cgit v0.12