Navigation in menubar: wrap around when using arrow past end or start of menubar.
See "Menu navigation in FLTK is different from Ubuntu X11 navigation" in fltk.general. Menubar wrapping is what macOS and gnome applications do.
This commit is contained in:
parent
0bb559c803
commit
c1a950e25f
@ -694,14 +694,17 @@ 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.
|
||||
// Fl_Menu_Button can generate menu=-1. This line fixes it and selects the first item.
|
||||
if (menu==-1)
|
||||
menu = 0;
|
||||
menuwindow &m = *(pp.p[menu]);
|
||||
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
||||
while (++item < m.numitems) {
|
||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||
while (m.numitems >= 2) {
|
||||
while (++item < m.numitems) {
|
||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||
}
|
||||
item = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -713,10 +716,12 @@ static int backward(int menu) { // previous item in menu menu if possible
|
||||
menustate &pp = *p;
|
||||
menuwindow &m = *(pp.p[menu]);
|
||||
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
||||
if (item < 0) item = m.numitems;
|
||||
while (--item >= 0) {
|
||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||
while (m.numitems >= 2) {
|
||||
while (--item >= 0) {
|
||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||
}
|
||||
item = m.numitems;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user