diff options
author | patthoyts@users.sourceforge.net <patthoyts> | 2009-12-30 00:24:27 (GMT) |
---|---|---|
committer | patthoyts@users.sourceforge.net <patthoyts> | 2009-12-30 00:24:27 (GMT) |
commit | 756af4c164b8563a0e58dd41f9e66a660f09026b (patch) | |
tree | 9268c889a4fe88e15101630195dd215218a89219 /generic/tkMenu.c | |
parent | 26b1352471d1b360c1905a4e2d7dd5434f542166 (diff) | |
download | tk-756af4c164b8563a0e58dd41f9e66a660f09026b.zip tk-756af4c164b8563a0e58dd41f9e66a660f09026b.tar.gz tk-756af4c164b8563a0e58dd41f9e66a660f09026b.tar.bz2 |
Patch 2879789: Make torn-off menu entrys activate across whole window
The torn-off menu entries do not activate except immediately over the
label or icon. If the window containing the torn-off menu is expanded
then a lot of dead space may be created, including the cascade arrow.
This patch fixes this making the whole width for any menu entry capable
of activation when the pointer hovers over the item.
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 479dd0c..7c95f32 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.53 2009/12/09 10:45:30 dkf Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.54 2009/12/30 00:24:27 patthoyts Exp $ */ /* @@ -2928,16 +2928,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. * *---------------------------------------------------------------------- */ @@ -2952,6 +2952,7 @@ GetIndexFromCoords( int x, y, i; const char *p; char *end; + int x2, borderwidth, max; TkRecomputeMenu(menuPtr); p = string + 1; @@ -2959,6 +2960,8 @@ GetIndexFromCoords( if (end == p) { goto error; } + Tk_GetPixelsFromObj(interp, menuPtr->tkwin, + menuPtr->borderWidthPtr, &borderwidth); if (*end == ',') { x = y; p = end + 1; @@ -2967,23 +2970,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: |