diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2009-12-30 00:29:38 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2009-12-30 00:29:38 (GMT) |
commit | 5834454dfdb57f33bae61fb49206c33584e05ee6 (patch) | |
tree | 01453f8a2d27c30ef58e92f6ab378fa9d8488d62 /generic/tkMenu.c | |
parent | 35abdae6af76bd2cb9012a57d901c748952bd2a6 (diff) | |
download | tk-5834454dfdb57f33bae61fb49206c33584e05ee6.zip tk-5834454dfdb57f33bae61fb49206c33584e05ee6.tar.gz tk-5834454dfdb57f33bae61fb49206c33584e05ee6.tar.bz2 |
Patch 2879789: Make torn-off menu entrys activate across whole window
backported from HEAD.
Diffstat (limited to 'generic/tkMenu.c')
-rw-r--r-- | generic/tkMenu.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 2db5e70..98f3f60 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.41.2.2 2009/04/10 16:16:04 das Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.41.2.3 2009/12/30 00:29:38 patthoyts Exp $ */ /* @@ -2905,16 +2905,16 @@ MenuDoYPosition( * * GetIndexFromCoords -- * - * Given a string of the form "@int", return the menu item corresponding - * to int. + * Given a string of the form "@integer", return the menu item + * corresponding to the provided y-coordinate in the menu window. * * Results: * If int is a valid number, *indexPtr will be the number of the - * menuentry that is the correct height. If int is invaled, *indexPtr + * menuentry that is the correct height. If int is invalid, *indexPtr * will be unchanged. Returns appropriate Tcl error number. * * Side effects: - * If int is invalid, interp's result will set to NULL. + * If int is invalid, interp's result will be set to NULL. * *---------------------------------------------------------------------- */ @@ -2928,6 +2928,7 @@ GetIndexFromCoords( { int x, y, i; char *p, *end; + int x2, borderwidth, max; TkRecomputeMenu(menuPtr); p = string + 1; @@ -2935,6 +2936,8 @@ GetIndexFromCoords( if (end == p) { goto error; } + Tk_GetPixelsFromObj(interp, menuPtr->tkwin, + menuPtr->borderWidthPtr, &borderwidth); if (*end == ',') { x = y; p = end + 1; @@ -2943,23 +2946,32 @@ GetIndexFromCoords( goto error; } } else { - Tk_GetPixelsFromObj(interp, menuPtr->tkwin, - menuPtr->borderWidthPtr, &x); + x = borderwidth; } + *indexPtr = -1; + + /* set the width of the final column to the remainder of the window + * being aware of windows that may not be mapped yet. + */ + max = Tk_IsMapped(menuPtr->tkwin) + ? Tk_Width(menuPtr->tkwin) : Tk_ReqWidth(menuPtr->tkwin); + max -= borderwidth; + for (i = 0; i < menuPtr->numEntries; i++) { + if (menuPtr->entries[i]->entryFlags & ENTRY_LAST_COLUMN) { + x2 = max; + } else { + x2 = menuPtr->entries[i]->x + menuPtr->entries[i]->width; + } if ((x >= menuPtr->entries[i]->x) && (y >= menuPtr->entries[i]->y) - && (x < (menuPtr->entries[i]->x + menuPtr->entries[i]->width)) + && (x < x2) && (y < (menuPtr->entries[i]->y + menuPtr->entries[i]->height))) { + *indexPtr = i; break; } } - if (i >= menuPtr->numEntries) { - /* i = menuPtr->numEntries - 1; */ - i = -1; - } - *indexPtr = i; return TCL_OK; error: |