diff options
| author | Bill Spitzak <spitzak@gmail.com> | 2000-10-17 07:39:06 +0000 |
|---|---|---|
| committer | Bill Spitzak <spitzak@gmail.com> | 2000-10-17 07:39:06 +0000 |
| commit | 710dcef237366e052ef74e68189546db6789e980 (patch) | |
| tree | 274204eef0a88f960d2bceef4ed9fbc4a3afcb3f /src/Fl_Menu_add.cxx | |
| parent | 12af97429349a181dee2dc295a43c2e4d3c692b4 (diff) | |
Fl_Menu_::add() ignores '&' signs when comparing menu items, so you don't
have to make the shortcuts the same all the time.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1316 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu_add.cxx')
| -rw-r--r-- | src/Fl_Menu_add.cxx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Fl_Menu_add.cxx b/src/Fl_Menu_add.cxx index 5d88a67d1..db10d8451 100644 --- a/src/Fl_Menu_add.cxx +++ b/src/Fl_Menu_add.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu_add.cxx,v 1.9.2.7 2000/06/05 21:20:54 mike Exp $" +// "$Id: Fl_Menu_add.cxx,v 1.9.2.8 2000/10/17 07:39:06 spitzak Exp $" // // Menu utilities for the Fast Light Tool Kit (FLTK). // @@ -78,6 +78,22 @@ static Fl_Menu_Item* insert( return array; } +// Comparison that does not care about deleted '&' signs: +static int compare(const char* a, const char* b) { + for (;;) { + int n = *a-*b; + if (n) { + if (*a == '&') a++; + else if (*b == '&') b++; + else return n; + } else if (*a) { + a++; b++; + } else { + return 0; + } + } +} + // Add an item. The text is split at '/' characters to automatically // produce submenus (actually a totally unnecessary feature as you can // now add submenu titles directly by setting SUBMENU in the flags): @@ -111,7 +127,7 @@ int Fl_Menu_Item::add( /* find a matching menu title: */ for (; m->text; m = m->next()) - if (m->flags&FL_SUBMENU && !strcmp(item, m->text)) break; + if (m->flags&FL_SUBMENU && !compare(item, m->text)) break; if (!m->text) { /* create a new menu */ int n = m-array; @@ -127,7 +143,7 @@ int Fl_Menu_Item::add( /* find a matching menu item: */ for (; m->text; m = m->next()) - if (!strcmp(m->text,item)) break; + if (!compare(m->text,item)) break; if (!m->text) { /* add a new menu item */ int n = m-array; @@ -237,5 +253,5 @@ void Fl_Menu_::remove(int i) { } // -// End of "$Id: Fl_Menu_add.cxx,v 1.9.2.7 2000/06/05 21:20:54 mike Exp $". +// End of "$Id: Fl_Menu_add.cxx,v 1.9.2.8 2000/10/17 07:39:06 spitzak Exp $". // |
