diff options
author | jingham <jingham@noemail.net> | 1999-06-16 05:36:45 (GMT) |
---|---|---|
committer | jingham <jingham@noemail.net> | 1999-06-16 05:36:45 (GMT) |
commit | 1ab597e11b964960febacdbf5d7a0e4222aa2638 (patch) | |
tree | 5a67bd0ae7ad96224d7b11b313736d4c9c5fd48c | |
parent | 3c07b4cf476904cdb64ae6a4638df9960440ee0e (diff) | |
download | tk-1ab597e11b964960febacdbf5d7a0e4222aa2638.zip tk-1ab597e11b964960febacdbf5d7a0e4222aa2638.tar.gz tk-1ab597e11b964960febacdbf5d7a0e4222aa2638.tar.bz2 |
Fix a bug in the region calculation for popup menus which would cause the popup to get posted in the wrong place if the menu was going to stick off the bottom of the screen.
FossilOrigin-Name: ce98dd35444b216a6f3a9677cbe5cf392ed3a126
-rw-r--r-- | mac/tkMacMenu.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c index b4bcce5..4940269 100644 --- a/mac/tkMacMenu.c +++ b/mac/tkMacMenu.c @@ -8,13 +8,14 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacMenu.c,v 1.9 1999/05/22 06:33:19 jingham Exp $ + * RCS: @(#) $Id: tkMacMenu.c,v 1.10 1999/06/16 05:36:46 jingham Exp $ */ #include "tkMacInt.h" #include "tkMenuButton.h" #include "tkMenu.h" #include "tkColor.h" +#include "tkMacInt.h" #undef Status #include <Menus.h> #include <OSUtils.h> @@ -3159,12 +3160,29 @@ MenuDefProc( if (menuPtr->totalHeight > maxMenuHeight) { menuRectPtr->top = GetMBarHeight(); } else { + int delta; menuRectPtr->top = hitPt.h; if (oldItem >= 0) { menuRectPtr->top -= menuPtr->entries[oldItem]->y; } - if (menuRectPtr->top + menuPtr->totalHeight > maxMenuHeight) { - menuRectPtr->top -= maxMenuHeight - menuPtr->totalHeight; + + if (menuRectPtr->top < GetMBarHeight()) { + /* Displace downward if the menu would stick off the + * top of the screen. + */ + + menuRectPtr->top = GetMBarHeight() + SCREEN_MARGIN; + } else { + /* + * Or upward if the menu sticks off the + * bottom end... + */ + + delta = menuRectPtr->top + menuPtr->totalHeight + - maxMenuHeight; + if (delta > 0) { + menuRectPtr->top -= delta; + } } } menuRectPtr->left = hitPt.v; @@ -3177,6 +3195,8 @@ MenuDefProc( } else { *whichItem = menuRectPtr->top; } + globalsPtr->menuTop = *whichItem; + globalsPtr->menuBottom = menuRectPtr->bottom; break; } } |