summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-02-26 13:03:21 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-02-26 13:03:21 +0000
commit4a802a315952a1392a82e3dc42c7316b540320f9 (patch)
treefb600b123307a93ee0532fdc976df353f8ecdc62 /src
parent47bcd46d26814b78897b315325b83de57bc78d1d (diff)
Fixed menu item counting issue in Fluid (STR #2322), Added Fl_Menu_::find_item by callback
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7150 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Menu_.cxx36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/Fl_Menu_.cxx b/src/Fl_Menu_.cxx
index 0775ecfce..62c73600e 100644
--- a/src/Fl_Menu_.cxx
+++ b/src/Fl_Menu_.cxx
@@ -99,11 +99,10 @@ int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *findite
}
/**
- Find menu item index, given a menu pathname such as "Edit/Copy".
-
- Will also return submenu items, eg. "Edit".
-
- Returns NULL if not found.
+ Find menu item index, given a menu pathname such as "Edit/Copy".
+
+ This method finds a menu item in a menu array, also traversing submenus, but
+ not submenu pointers.
\b Example:
\code
@@ -121,8 +120,11 @@ int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *findite
}
\endcode
\returns The item found, or NULL if not found.
- \see item_pathname()
+ \see
+ \param name path and name of the menu item
+ \return NULL if not found
+ \see Fl_Menu_::find_item(Fl_Callback*), item_pathname()
*/
const Fl_Menu_Item * Fl_Menu_::find_item(const char *name) {
char menupath[1024] = ""; // File/Export
@@ -158,6 +160,28 @@ const Fl_Menu_Item * Fl_Menu_::find_item(const char *name) {
}
/**
+ Find menu item index given a callback.
+
+ This method finds a menu item in a menu array, also traversing submenus, but
+ not submenu pointers. This is useful if an application uses
+ internationalisation and a menu item can not be found using its label. This
+ search is also much faster.
+
+ \param cb find the first item with this callback
+ \return NULL if not found
+ \see Fl_Menu_::find_item(const char*)
+ */
+const Fl_Menu_Item * Fl_Menu_::find_item(Fl_Callback *cb) {
+ for ( int t=0; t < size(); t++ ) {
+ const Fl_Menu_Item *m = menu_ + t;
+ if (m->callback_==cb) {
+ return m;
+ }
+ }
+ return (const Fl_Menu_Item *)0;
+}
+
+/**
The value is the index into menu() of the last item chosen by
the user. It is zero initially. You can set it as an integer, or set
it with a pointer to a menu item. The set routines return non-zero if