diff -r 029e126e3439 -r 4c8d0193ebe0 src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp Thu May 08 11:50:34 2008 +0000 +++ b/src/toolbar_gui.cpp Thu May 08 12:59:47 2008 +0000 @@ -77,6 +77,26 @@ return pos; } +/** + * In a window with menu_d custom extension, retrieve the menu item number from a position + * @param w Window holding the menu items + * @param x X coordinate of the position + * @param y Y coordinate of the position + * @return Index number of the menu item, or \c -1 if no valid selection under position + */ +static int GetMenuItemIndex(const Window *w, int x, int y) +{ + if ((x -= w->left) >= 0 && x < w->width && (y -= w->top + 1) >= 0) { + y /= 10; + + if (y < WP(w, const menu_d).item_count && + !HasBit(WP(w, const menu_d).disabled_items, y)) { + return y; + } + } + return -1; +} + /* --- Pausing --- */ static void ToolbarPauseClick(Window *w)