summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2010-11-11 09:12:05 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2010-11-11 09:12:05 +0000
commit2105f203f18ef44e4710fc07148f1a2e5376cc68 (patch)
treeb817a490852c964657aff73d9699ba1135943203 /src/Fl_Menu.cxx
parent832c8787ab3769d6120b6b9c87581aae16cb3558 (diff)
Fixed menu and shortcut handling (STR #2243). This partly reverts the
fix for STR #2199 - for details see STR #2243. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7816 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index e341b868a..7f9df8e1f 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -956,44 +956,56 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
}
/**
- This method is called by widgets that want to display menus. The menu
- stays up until the user picks an item or dismisses it. The selected
- item (or NULL if none) is returned. <I>This does not do the
- callbacks or change the state of check or radio items.</I>
- <P>X,Y is the position of the mouse cursor, relative to the
+ This method is called by widgets that want to display menus.
+
+ The menu stays up until the user picks an item or dismisses it.
+ The selected item (or NULL if none) is returned. <I>This does not
+ do the callbacks or change the state of check or radio items.</I>
+
+ X,Y is the position of the mouse cursor, relative to the
window that got the most recent event (usually you can pass
- Fl::event_x() and Fl::event_y() unchanged here). </P>
- <P>title is a character string title for the menu. If
- non-zero a small box appears above the menu with the title in it. </P>
- <P>The menu is positioned so the cursor is centered over the item
- picked. This will work even if picked is in a submenu.
- If picked is zero or not in the menu item table the menu is
- positioned with the cursor in the top-left corner. </P>
- <P>button is a pointer to an
- Fl_Menu_ from which the color and boxtypes for the menu are
- pulled. If NULL then defaults are used.
+ Fl::event_x() and Fl::event_y() unchanged here).
+
+ \p title is a character string title for the menu. If
+ non-zero a small box appears above the menu with the title in it.
+
+ The menu is positioned so the cursor is centered over the item
+ picked. This will work even if \p picked is in a submenu.
+ If \p picked is zero or not in the menu item table the menu is
+ positioned with the cursor in the top-left corner.
+
+ \p button is a pointer to an Fl_Menu_ from which the color and
+ boxtypes for the menu are pulled. If NULL then defaults are used.
*/
const Fl_Menu_Item* Fl_Menu_Item::popup(
int X, int Y,
const char* title,
const Fl_Menu_Item* picked,
- const Fl_Menu_* but
+ const Fl_Menu_* button
) const {
static Fl_Menu_Item dummy; // static so it is all zeros
dummy.text = title;
- return pulldown(X, Y, 0, 0, picked, but, title ? &dummy : 0);
+ return pulldown(X, Y, 0, 0, picked, button, title ? &dummy : 0);
}
/**
Search only the top level menu for a shortcut.
- Either &x in the label or the shortcut fields are used.
+ Either &x in the label or the shortcut fields are used.
+
+ This tests the current event, which must be an FL_KEYBOARD or
+ FL_SHORTCUT, against a shortcut value.
+
+ \param ip returns the index of the item, if \p ip is not NULL.
+ \param require_alt if true: match only if Alt key is pressed.
+
+ \return found Fl_Menu_Item or NULL
*/
-const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const {
+const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip, const bool require_alt) const {
const Fl_Menu_Item* m = first();
if (m) for (int ii = 0; m->text; m = m->next(), ii++) {
if (m->activevisible()) {
if (Fl::test_shortcut(m->shortcut_)
- || Fl_Widget::test_shortcut(m->text)) {
+ || Fl_Widget::test_shortcut(m->text, require_alt)) {
if (ip) *ip=ii;
return m;
}