summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx362
1 files changed, 178 insertions, 184 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index fa671188d..0274501b8 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Menu code for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2015 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
// Warning: this menu code is quite a mess!
@@ -70,7 +68,7 @@ int Fl_Menu_Item::size() const {
}
}
-// Advance a pointer to next visible or invisible item of a menu array,
+// Advance a pointer to next visible or invisible item of a menu array,
// skipping the contents of submenus.
static const Fl_Menu_Item* next_visible_or_not(const Fl_Menu_Item* m) {
int nest = 0;
@@ -125,15 +123,15 @@ class menuwindow : public Fl_Menu_Window {
public:
menutitle* title;
int handle(int);
- int itemheight; // zero == menubar
+ int itemheight; // zero == menubar
int numitems;
int selected;
- int drawn_selected; // last redraw has this selected
+ int drawn_selected; // last redraw has this selected
int shortcutWidth;
const Fl_Menu_Item* menu;
menuwindow(const Fl_Menu_Item* m, int X, int Y, int W, int H,
- const Fl_Menu_Item* picked, const Fl_Menu_Item* title,
- int menubar = 0, int menubar_title = 0, int right_edge = 0);
+ const Fl_Menu_Item* picked, const Fl_Menu_Item* title,
+ int menubar = 0, int menubar_title = 0, int right_edge = 0);
~menuwindow();
void set_selected(int);
int find_selected(int mx, int my);
@@ -145,9 +143,9 @@ public:
extern char fl_draw_shortcut;
-/**
- Measures width of label, including effect of & characters.
- Optionally, can get height if hp is not NULL.
+/**
+ Measures width of label, including effect of & characters.
+ Optionally, can get height if hp is not NULL.
*/
int Fl_Menu_Item::measure(int* hp, const Fl_Menu_* m) const {
Fl_Label l;
@@ -168,7 +166,7 @@ int Fl_Menu_Item::measure(int* hp, const Fl_Menu_* m) const {
/** Draws the menu item in bounding box x,y,w,h, optionally selects the item. */
void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
- int selected) const {
+ int selected) const {
Fl_Label l;
l.value = text;
l.image = 0;
@@ -184,11 +182,11 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
Fl_Boxtype b = m && m->down_box() ? m->down_box() : FL_FLAT_BOX;
if (fl_contrast(r,color)!=r) { // back compatibility boxtypes
if (selected == 2) { // menu title
- r = color;
- b = m ? m->box() : FL_UP_BOX;
+ r = color;
+ b = m ? m->box() : FL_UP_BOX;
} else {
- r = (Fl_Color)(FL_COLOR_CUBE-1); // white
- l.color = fl_contrast((Fl_Color)labelcolor_, r);
+ r = (Fl_Color)(FL_COLOR_CUBE-1); // white
+ l.color = fl_contrast((Fl_Color)labelcolor_, r);
}
} else {
l.color = fl_contrast((Fl_Color)labelcolor_, r);
@@ -209,64 +207,64 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
if (flags & FL_MENU_RADIO) {
fl_draw_box(FL_ROUND_DOWN_BOX, x+2, y+d, W, W, FL_BACKGROUND2_COLOR);
if (value()) {
- int tW = (W - Fl::box_dw(FL_ROUND_DOWN_BOX)) / 2 + 1;
- if ((W - tW) & 1) tW++; // Make sure difference is even to center
- int td = (W - tW) / 2;
+ int tW = (W - Fl::box_dw(FL_ROUND_DOWN_BOX)) / 2 + 1;
+ if ((W - tW) & 1) tW++; // Make sure difference is even to center
+ int td = (W - tW) / 2;
if (Fl::is_scheme("gtk+")) {
- fl_color(FL_SELECTION_COLOR);
- tW --;
- fl_pie(x + td + 1, y + d + td - 1, tW + 3, tW + 3, 0.0, 360.0);
- fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.2f));
- } else fl_color(labelcolor_);
-
- switch (tW) {
- // Larger circles draw fine...
- default :
+ fl_color(FL_SELECTION_COLOR);
+ tW --;
+ fl_pie(x + td + 1, y + d + td - 1, tW + 3, tW + 3, 0.0, 360.0);
+ fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.2f));
+ } else fl_color(labelcolor_);
+
+ switch (tW) {
+ // Larger circles draw fine...
+ default :
fl_pie(x + td + 2, y + d + td, tW, tW, 0.0, 360.0);
- break;
+ break;
// Small circles don't draw well on many systems...
- case 6 :
- fl_rectf(x + td + 4, y + d + td, tW - 4, tW);
- fl_rectf(x + td + 3, y + d + td + 1, tW - 2, tW - 2);
- fl_rectf(x + td + 2, y + d + td + 2, tW, tW - 4);
- break;
-
- case 5 :
- case 4 :
- case 3 :
- fl_rectf(x + td + 3, y + d + td, tW - 2, tW);
- fl_rectf(x + td + 2, y + d + td + 1, tW, tW - 2);
- break;
-
- case 2 :
- case 1 :
- fl_rectf(x + td + 2, y + d + td, tW, tW);
- break;
- }
-
- if (Fl::is_scheme("gtk+")) {
- fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.5));
- fl_arc(x + td + 2, y + d + td, tW + 1, tW + 1, 60.0, 180.0);
- }
+ case 6 :
+ fl_rectf(x + td + 4, y + d + td, tW - 4, tW);
+ fl_rectf(x + td + 3, y + d + td + 1, tW - 2, tW - 2);
+ fl_rectf(x + td + 2, y + d + td + 2, tW, tW - 4);
+ break;
+
+ case 5 :
+ case 4 :
+ case 3 :
+ fl_rectf(x + td + 3, y + d + td, tW - 2, tW);
+ fl_rectf(x + td + 2, y + d + td + 1, tW, tW - 2);
+ break;
+
+ case 2 :
+ case 1 :
+ fl_rectf(x + td + 2, y + d + td, tW, tW);
+ break;
+ }
+
+ if (Fl::is_scheme("gtk+")) {
+ fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.5));
+ fl_arc(x + td + 2, y + d + td, tW + 1, tW + 1, 60.0, 180.0);
+ }
}
} else {
fl_draw_box(FL_DOWN_BOX, x+2, y+d, W, W, FL_BACKGROUND2_COLOR);
if (value()) {
- if (Fl::is_scheme("gtk+")) {
- fl_color(FL_SELECTION_COLOR);
- } else {
- fl_color(labelcolor_);
- }
- int tx = x + 5;
- int tw = W - 6;
- int d1 = tw/3;
- int d2 = tw-d1;
- int ty = y + d + (W+d2)/2-d1-2;
- for (int n = 0; n < 3; n++, ty++) {
- fl_line(tx, ty, tx+d1, ty+d1);
- fl_line(tx+d1, ty+d1, tx+tw-1, ty+d1-d2+1);
- }
+ if (Fl::is_scheme("gtk+")) {
+ fl_color(FL_SELECTION_COLOR);
+ } else {
+ fl_color(labelcolor_);
+ }
+ int tx = x + 5;
+ int tw = W - 6;
+ int d1 = tw/3;
+ int d2 = tw-d1;
+ int ty = y + d + (W+d2)/2-d1-2;
+ for (int n = 0; n < 3; n++, ty++) {
+ fl_line(tx, ty, tx+d1, ty+d1);
+ fl_line(tx+d1, ty+d1, tx+tw-1, ty+d1-d2+1);
+ }
}
}
x += W + 3;
@@ -289,8 +287,8 @@ menutitle::menutitle(int X, int Y, int W, int H, const Fl_Menu_Item* L) :
}
menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
- const Fl_Menu_Item* picked, const Fl_Menu_Item* t,
- int menubar, int menubar_title, int right_edge)
+ const Fl_Menu_Item* picked, const Fl_Menu_Item* t,
+ int menubar, int menubar_title, int right_edge)
: Fl_Menu_Window(X, Y, Wp, Hp, 0)
{
int scr_x, scr_y, scr_w, scr_h;
@@ -340,10 +338,10 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (t) Wtitle = t->measure(&Htitle, button) + 12;
int W = 0;
if (m) for (; m->text; m = m->next()) {
- int hh;
+ int hh;
int w1 = m->measure(&hh, button);
if (hh+Fl::menu_linespacing()>itemheight) itemheight = hh+Fl::menu_linespacing();
- if (m->flags&(FL_SUBMENU|FL_SUBMENU_POINTER))
+ if (m->flags&(FL_SUBMENU|FL_SUBMENU_POINTER))
w1 += FL_NORMAL_SIZE;
if (w1 > W) W = w1;
// calculate the maximum width of all shortcuts
@@ -374,8 +372,8 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (Wp > W) W = Wp;
if (Wtitle > W) W = Wtitle;
- if (X < scr_x) X = scr_x;
- // this change improves popup submenu positioning at right screen edge,
+ if (X < scr_x) X = scr_x;
+ // this change improves popup submenu positioning at right screen edge,
// but it makes right_edge argument useless
//if (X > scr_x+scr_w-W) X = right_edge-W;
if (X > scr_x+scr_w-W) X = scr_x+scr_w-W;
@@ -512,7 +510,7 @@ void menutitle::draw() {
}
void menuwindow::draw() {
- if (damage() != FL_DAMAGE_CHILD) { // complete redraw
+ if (damage() != FL_DAMAGE_CHILD) { // complete redraw
fl_draw_box(box(), 0, 0, w(), h(), button ? button->color() : color());
if (menu) {
const Fl_Menu_Item* m; int j;
@@ -523,7 +521,7 @@ void menuwindow::draw() {
drawentry(menu->next(drawn_selected), drawn_selected, 1);
drawentry(menu->next(selected), selected, 1);
}
- }
+ }
drawn_selected = selected;
}
@@ -592,9 +590,9 @@ int menuwindow::is_inside(int mx, int my) {
// of windows is slow, and we don't want to fall behind the events.
// values for menustate.state:
-#define INITIAL_STATE 0 // no mouse up or down since popup() called
-#define PUSH_STATE 1 // mouse has been pushed on a normal item
-#define DONE_STATE 2 // exit the popup, the current item was picked
+#define INITIAL_STATE 0 // no mouse up or down since popup() called
+#define PUSH_STATE 1 // mouse has been pushed on a normal item
+#define DONE_STATE 2 // exit the popup, the current item was picked
#define MENU_PUSH_STATE 3 // mouse has been pushed on a menu title
struct menustate {
@@ -636,7 +634,7 @@ static void setitem(int m, int n) {
static int forward(int menu) { // go to next item in menu menu if possible
menustate &pp = *p;
// Fl_Menu_Button can generate menu=-1. This line fixes it and selectes the first item.
- if (menu==-1)
+ if (menu==-1)
menu = 0;
menuwindow &m = *(pp.p[menu]);
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
@@ -664,19 +662,19 @@ int menuwindow::handle(int e) {
and "svn blame" shows it is here to fix STR #449.
But this STR is Mac OS-specific.
So, it is unclear why handle_part2() is called also for X11.
-
+
Furthermore, calling handle_part2() for X11 renders the
fix for STR #2619 below necessary. If handle_part2() is not called under X11,
then STR #2619 does not occur. need_menu_handle_part1_extra() activates this fix.
-
+
FLTK 1.3.4 behavior:
Fl::system_driver()->need_menu_handle_part2() returns true on Mac + X11
Fl::system_driver()->need_menu_handle_part1_extra() returns true on X11
-
+
Alternative behavior that seems equally correct:
Fl::system_driver()->need_menu_handle_part2() returns true on Mac
need_menu_handle_part1_extra() does not exist
-
+
Other alternative:
Neither need_menu_handle_part2() nor need_menu_handle_part1_extra() exist
--> the menuwindow code is entirely cross-platform and simpler.
@@ -708,7 +706,7 @@ int menuwindow::handle_part2(int e, int ret) {
menuwindow *mw = pp.p[--i];
if (mw) {
mw->hide();
- if (mw->title)
+ if (mw->title)
mw->title->hide();
}
}
@@ -748,13 +746,13 @@ int menuwindow::handle_part1(int e) {
return 1;
case FL_Right:
if (pp.menubar && (pp.menu_number<=0 || (pp.menu_number==1 && pp.nummenus==2)))
- forward(0);
+ forward(0);
else if (pp.menu_number < pp.nummenus-1) forward(pp.menu_number+1);
return 1;
case FL_Left:
if (pp.menubar && pp.menu_number<=1) backward(0);
else if (pp.menu_number>0)
- setitem(pp.menu_number-1, pp.p[pp.menu_number-1]->selected);
+ setitem(pp.menu_number-1, pp.p[pp.menu_number-1]->selected);
return 1;
case FL_Enter:
case FL_KP_Enter:
@@ -767,16 +765,16 @@ int menuwindow::handle_part1(int e) {
return 1;
}
break;
- case FL_SHORTCUT:
+ case FL_SHORTCUT:
{
for (int mymenu = pp.nummenus; mymenu--;) {
- menuwindow &mw = *(pp.p[mymenu]);
- int item; const Fl_Menu_Item* m = mw.menu->find_shortcut(&item);
- if (m) {
- setitem(m, mymenu, item);
- if (!m->submenu()) pp.state = DONE_STATE;
- return 1;
- }
+ menuwindow &mw = *(pp.p[mymenu]);
+ int item; const Fl_Menu_Item* m = mw.menu->find_shortcut(&item);
+ if (m) {
+ setitem(m, mymenu, item);
+ if (!m->submenu()) pp.state = DONE_STATE;
+ return 1;
+ }
}
}
break;
@@ -796,60 +794,60 @@ int menuwindow::handle_part1(int e) {
int item=0; int mymenu = pp.nummenus-1;
// Clicking or dragging outside menu cancels it...
if ((!pp.menubar || mymenu) && !pp.is_inside(mx, my)) {
- setitem(0, -1, 0);
- if (e==FL_PUSH)
- pp.state = DONE_STATE;
- return 1;
+ setitem(0, -1, 0);
+ if (e==FL_PUSH)
+ pp.state = DONE_STATE;
+ return 1;
}
for (mymenu = pp.nummenus-1; ; mymenu--) {
- item = pp.p[mymenu]->find_selected(mx, my);
- if (item >= 0)
- break;
- if (mymenu <= 0) {
- // buttons in menubars must be deselected if we move outside of them!
- if (pp.menu_number==-1 && e==FL_PUSH) {
- pp.state = DONE_STATE;
- return 1;
- }
- if (pp.current_item && pp.menu_number==0 && !pp.current_item->submenu()) {
- if (e==FL_PUSH)
- pp.state = DONE_STATE;
- setitem(0, -1, 0);
- return 1;
- }
- // all others can stay selected
- return 0;
- }
+ item = pp.p[mymenu]->find_selected(mx, my);
+ if (item >= 0)
+ break;
+ if (mymenu <= 0) {
+ // buttons in menubars must be deselected if we move outside of them!
+ if (pp.menu_number==-1 && e==FL_PUSH) {
+ pp.state = DONE_STATE;
+ return 1;
+ }
+ if (pp.current_item && pp.menu_number==0 && !pp.current_item->submenu()) {
+ if (e==FL_PUSH)
+ pp.state = DONE_STATE;
+ setitem(0, -1, 0);
+ return 1;
+ }
+ // all others can stay selected
+ return 0;
+ }
}
if (my == 0 && item > 0) setitem(mymenu, item - 1);
else setitem(mymenu, item);
if (e == FL_PUSH) {
- if (pp.current_item && pp.current_item->submenu() // this is a menu title
- && item != pp.p[mymenu]->selected // and it is not already on
- && !pp.current_item->callback_) // and it does not have a callback
- pp.state = MENU_PUSH_STATE;
- else
- pp.state = PUSH_STATE;
+ if (pp.current_item && pp.current_item->submenu() // this is a menu title
+ && item != pp.p[mymenu]->selected // and it is not already on
+ && !pp.current_item->callback_) // and it does not have a callback
+ pp.state = MENU_PUSH_STATE;
+ else
+ pp.state = PUSH_STATE;
}
}
return 1;
case FL_RELEASE:
// Mouse must either be held down/dragged some, or this must be
// the second click (not the one that popped up the menu):
- if ( !Fl::event_is_click()
- || pp.state == PUSH_STATE
+ if ( !Fl::event_is_click()
+ || pp.state == PUSH_STATE
|| (pp.menubar && pp.current_item && !pp.current_item->submenu()) // button
- ) {
+ ) {
#if 0 // makes the check/radio items leave the menu up
const Fl_Menu_Item* m = pp.current_item;
if (m && button && (m->flags & (FL_MENU_TOGGLE|FL_MENU_RADIO))) {
- ((Fl_Menu_*)button)->picked(m);
- pp.p[pp.menu_number]->redraw();
+ ((Fl_Menu_*)button)->picked(m);
+ pp.p[pp.menu_number]->redraw();
} else
#endif
// do nothing if they try to pick inactive items
if (!pp.current_item || pp.current_item->activevisible())
- pp.state = DONE_STATE;
+ pp.state = DONE_STATE;
}
return 1;
}
@@ -925,8 +923,8 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
{
for (int k = menubar; k < pp.nummenus; k++) {
if (!pp.p[k]->shown()) {
- if (pp.p[k]->title) pp.p[k]->title->show();
- pp.p[k]->show();
+ if (pp.p[k]->title) pp.p[k]->title->show();
+ pp.p[k]->show();
}
}
}
@@ -936,7 +934,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
const Fl_Menu_Item* oldi = pp.current_item;
Fl::wait();
if (pbutton && wp.deleted()) // menu widget has been deleted (STR #3503)
- break;
+ break;
if (pp.state == DONE_STATE) break; // done.
if (pp.current_item == oldi) continue;
}
@@ -972,54 +970,54 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
else menutable = (Fl_Menu_Item*)(m)->user_data_;
// figure out where new menu goes:
int nX, nY;
- if (!pp.menu_number && pp.menubar) { // menu off a menubar:
- nX = cw.x() + cw.titlex(pp.item_number);
- nY = cw.y() + cw.h();
- initial_item = 0;
+ if (!pp.menu_number && pp.menubar) { // menu off a menubar:
+ nX = cw.x() + cw.titlex(pp.item_number);
+ nY = cw.y() + cw.h();
+ initial_item = 0;
} else {
- nX = cw.x() + cw.w();
- nY = cw.y() + pp.item_number * cw.itemheight;
- title = 0;
+ nX = cw.x() + cw.w();
+ nY = cw.y() + pp.item_number * cw.itemheight;
+ title = 0;
}
if (initial_item) { // bring up submenu containing initial item:
- menuwindow* n = new menuwindow(menutable,X,Y,W,H,initial_item,title,0,0,cw.x());
- pp.p[pp.nummenus++] = n;
- // move all earlier menus to line up with this new one:
- if (n->selected>=0) {
- int dy = n->y()-nY;
- int dx = n->x()-nX;
- int waX, waY, waW, waH;
- Fl::screen_work_area(waX, waY, waW, waH, X, Y);
- for (int menu = 0; menu <= pp.menu_number; menu++) {
- menuwindow* tt = pp.p[menu];
- int nx = tt->x()+dx; if (nx < waX) {nx = waX; dx = -tt->x() + waX;}
- int ny = tt->y()+dy; if (ny < waY) {ny = waY; dy = -tt->y() + waY;}
- tt->position(nx, ny);
- }
- setitem(pp.nummenus-1, n->selected);
- goto STARTUP;
- }
+ menuwindow* n = new menuwindow(menutable,X,Y,W,H,initial_item,title,0,0,cw.x());
+ pp.p[pp.nummenus++] = n;
+ // move all earlier menus to line up with this new one:
+ if (n->selected>=0) {
+ int dy = n->y()-nY;
+ int dx = n->x()-nX;
+ int waX, waY, waW, waH;
+ Fl::screen_work_area(waX, waY, waW, waH, X, Y);
+ for (int menu = 0; menu <= pp.menu_number; menu++) {
+ menuwindow* tt = pp.p[menu];
+ int nx = tt->x()+dx; if (nx < waX) {nx = waX; dx = -tt->x() + waX;}
+ int ny = tt->y()+dy; if (ny < waY) {ny = waY; dy = -tt->y() + waY;}
+ tt->position(nx, ny);
+ }
+ setitem(pp.nummenus-1, n->selected);
+ goto STARTUP;
+ }
} else if (pp.nummenus > pp.menu_number+1 &&
- pp.p[pp.menu_number+1]->menu == menutable) {
- // the menu is already up:
- while (pp.nummenus > pp.menu_number+2) delete pp.p[--pp.nummenus];
- pp.p[pp.nummenus-1]->set_selected(-1);
+ pp.p[pp.menu_number+1]->menu == menutable) {
+ // the menu is already up:
+ while (pp.nummenus > pp.menu_number+2) delete pp.p[--pp.nummenus];
+ pp.p[pp.nummenus-1]->set_selected(-1);
} else {
- // delete all the old menus and create new one:
- while (pp.nummenus > pp.menu_number+1) delete pp.p[--pp.nummenus];
- pp.p[pp.nummenus++]= new menuwindow(menutable, nX, nY,
- title?1:0, 0, 0, title, 0, menubar,
- (title ? 0 : cw.x()) );
+ // delete all the old menus and create new one:
+ while (pp.nummenus > pp.menu_number+1) delete pp.p[--pp.nummenus];
+ pp.p[pp.nummenus++]= new menuwindow(menutable, nX, nY,
+ title?1:0, 0, 0, title, 0, menubar,
+ (title ? 0 : cw.x()) );
}
} else { // !m->submenu():
while (pp.nummenus > pp.menu_number+1) delete pp.p[--pp.nummenus];
if (!pp.menu_number && pp.menubar) {
- // kludge so "menubar buttons" turn "on" by using menu title:
- pp.fakemenu = new menuwindow(0,
- cw.x()+cw.titlex(pp.item_number),
- cw.y()+cw.h(), 0, 0,
- 0, m, 0, 1);
- pp.fakemenu->title->show();
+ // kludge so "menubar buttons" turn "on" by using menu title:
+ pp.fakemenu = new menuwindow(0,
+ cw.x()+cw.titlex(pp.item_number),
+ cw.y()+cw.h(), 0, 0,
+ 0, m, 0, 1);
+ pp.fakemenu->title->show();
}
}
}
@@ -1044,7 +1042,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
positioned with the cursor in the top-left corner.
\param[in] X,Y the position of the mouse cursor, relative to the
- window that got the most recent event (usually you can pass
+ window that got the most recent event (usually you can pass
Fl::event_x() and Fl::event_y() unchanged here).
\param[in] title a character string title for the menu. If
@@ -1070,10 +1068,10 @@ const Fl_Menu_Item* Fl_Menu_Item::popup(
}
/**
- Search only the top level menu for a shortcut.
+ Search only the top level menu for a shortcut.
Either &x in the label or the shortcut fields are used.
- This tests the current event, which must be an FL_KEYBOARD or
+ 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.
@@ -1086,9 +1084,9 @@ const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip, const bool require_alt)
if (m) for (int ii = 0; m->text; m = next_visible_or_not(m), ii++) {
if (m->active()) {
if (Fl::test_shortcut(m->shortcut_)
- || Fl_Widget::test_shortcut(m->text, require_alt)) {
- if (ip) *ip=ii;
- return m;
+ || Fl_Widget::test_shortcut(m->text, require_alt)) {
+ if (ip) *ip=ii;
+ return m;
}
}
}
@@ -1115,15 +1113,11 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
// if (Fl_Widget::test_shortcut(m->text)) return m;
// only return matches from lower menu if nothing found in top menu:
if (!ret && m->submenu()) {
- const Fl_Menu_Item* s =
- (m->flags&FL_SUBMENU) ? m+1:(const Fl_Menu_Item*)m->user_data_;
- ret = s->test_shortcut();
+ const Fl_Menu_Item* s =
+ (m->flags&FL_SUBMENU) ? m+1:(const Fl_Menu_Item*)m->user_data_;
+ ret = s->test_shortcut();
}
}
}
return ret;
}
-
-//
-// End of "$Id$".
-//