diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2011-06-01 11:12:10 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2011-06-01 11:12:10 (GMT) |
commit | 0c0d53b33023d1bf7dc53f5875f747031580d53b (patch) | |
tree | 609addb790b118af0c7b519e9282d667b2475044 | |
parent | 7667c648d04e8635346b149f6f6d58dae1998598 (diff) | |
parent | 04526fe293b1b59c39461441d8c3ac06218ad187 (diff) | |
download | tk-0c0d53b33023d1bf7dc53f5875f747031580d53b.zip tk-0c0d53b33023d1bf7dc53f5875f747031580d53b.tar.gz tk-0c0d53b33023d1bf7dc53f5875f747031580d53b.tar.bz2 |
Merged [Bug #3306909] and [Bug #3294593] from 8.5 (menu posting issues)
-rw-r--r-- | library/menu.tcl | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index e9d1c27..10d6888 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]] } } } @@ -1225,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 |