diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-09-05 14:45:51 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-09-05 14:45:57 +0200 |
| commit | 6bb5a81cee7e76e8a4e69f7f49869f39c1c382f0 (patch) | |
| tree | 2a6d6f73dd19dd52aaccd1d99b50a20bb53946d6 /src/Fl_Menu_.cxx | |
| parent | b2a41e08c3b9b5fbbd0c899537611b8e28e5993d (diff) | |
Adds some convenience methods.
fl_filename_absolute can no generate a path using arbitrary source paths.
Fl_Menu_ adds find_item_with_user_data and find_item_with_argument
Fl_String adds find(string, start)
Diffstat (limited to 'src/Fl_Menu_.cxx')
| -rw-r--r-- | src/Fl_Menu_.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Fl_Menu_.cxx b/src/Fl_Menu_.cxx index 28a476e02..1769af9a1 100644 --- a/src/Fl_Menu_.cxx +++ b/src/Fl_Menu_.cxx @@ -267,6 +267,40 @@ const Fl_Menu_Item * Fl_Menu_::find_item(Fl_Callback *cb) { } /** + Find the menu item for the given user data \p v. + + \param[in] v find the first item with this user data + \returns The item found, or NULL if not found + \see find_item(const char*) + */ +const Fl_Menu_Item* Fl_Menu_::find_item_with_user_data(void *v) { + for ( int t=0; t < size(); t++ ) { + const Fl_Menu_Item *m = menu_ + t; + if (m->user_data_==v) { + return m; + } + } + return (const Fl_Menu_Item *)NULL; +} + +/** + Find the menu item for the given user argument \p v. + + \param[in] v find the first item with this user argument + \returns The item found, or NULL if not found + \see find_item(const char*) + */ +const Fl_Menu_Item* Fl_Menu_::find_item_with_argument(long v) { + for ( int t=0; t < size(); t++ ) { + const Fl_Menu_Item *m = menu_ + t; + if (m->argument()==v) { + return m; + } + } + return (const Fl_Menu_Item *)NULL; +} + +/** 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 |
