summaryrefslogtreecommitdiffstats
path: root/library/menu.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2004-02-04 00:23:02 (GMT)
committerhobbs <hobbs@noemail.net>2004-02-04 00:23:02 (GMT)
commit18001472a1ea41ac386eacb16325c36e8414ea24 (patch)
treeef5480755b9c91dc499fcb8382610a72781c10bd /library/menu.tcl
parente1de3659a7b8ae5c0648a2dd62f93925b93ae417 (diff)
downloadtk-18001472a1ea41ac386eacb16325c36e8414ea24.zip
tk-18001472a1ea41ac386eacb16325c36e8414ea24.tar.gz
tk-18001472a1ea41ac386eacb16325c36e8414ea24.tar.bz2
* library/menu.tcl (::tk::MbPost): make menubuttons that post
above or below reverse direction when not enough space is available. FossilOrigin-Name: 285b96881f9a6fb2c3e71c9c01b466f6d8092fdd
Diffstat (limited to 'library/menu.tcl')
-rw-r--r--library/menu.tcl13
1 files changed, 11 insertions, 2 deletions
diff --git a/library/menu.tcl b/library/menu.tcl
index 21dd22d..c6d65bf 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -4,7 +4,7 @@
# It also implements keyboard traversal of menus and implements a few
# other utility procedures related to menus.
#
-# RCS: @(#) $Id: menu.tcl,v 1.18 2002/08/31 06:12:28 das Exp $
+# RCS: @(#) $Id: menu.tcl,v 1.18.2.1 2004/02/04 00:23:04 hobbs Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -280,11 +280,20 @@ proc ::tk::MbPost {w {x {}} {y {}}} {
above {
set x [winfo rootx $w]
set y [expr {[winfo rooty $w] - [winfo reqheight $menu]}]
+ # if we go offscreen to the top, show as 'below'
+ if {$y < 0} {
+ set y [expr {[winfo rooty $w] + [winfo height $w]}]
+ }
PostOverPoint $menu $x $y
}
below {
set x [winfo rootx $w]
set y [expr {[winfo rooty $w] + [winfo height $w]}]
+ # if we go offscreen to the bottom, show as 'above'
+ set mh [winfo reqheight $menu]
+ if {($y + $mh) > [winfo screenheight $w]} {
+ set y [expr {[winfo rooty $w] - $mh}]
+ }
PostOverPoint $menu $x $y
}
left {
@@ -336,7 +345,7 @@ proc ::tk::MbPost {w {x {}} {y {}}} {
PostOverPoint $menu $x $y [MenuFindName $menu [$w cget -text]]
} else {
PostOverPoint $menu [winfo rootx $w] [expr {[winfo rooty $w]+[winfo height $w]}]
- }
+ }
}
}
} msg]} {