Navigation in menubar: wrap around when using arrow past end or start of menubar.
Fix some border cases.
This commit is contained in:
parent
f44c163234
commit
fe4c94b4dc
@ -699,13 +699,14 @@ static int forward(int menu) { // go to next item in menu menu if possible
|
|||||||
menu = 0;
|
menu = 0;
|
||||||
menuwindow &m = *(pp.p[menu]);
|
menuwindow &m = *(pp.p[menu]);
|
||||||
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
||||||
while (m.numitems >= 2) {
|
do {
|
||||||
while (++item < m.numitems) {
|
while (++item < m.numitems) {
|
||||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||||
}
|
}
|
||||||
item = -1;
|
item = -1;
|
||||||
}
|
}
|
||||||
|
while (pp.menubar && pp.menu_number <= 0 && (!m.menu || m.menu->submenu()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,13 +717,14 @@ static int backward(int menu) { // previous item in menu menu if possible
|
|||||||
menustate &pp = *p;
|
menustate &pp = *p;
|
||||||
menuwindow &m = *(pp.p[menu]);
|
menuwindow &m = *(pp.p[menu]);
|
||||||
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
int item = (menu == pp.menu_number) ? pp.item_number : m.selected;
|
||||||
while (m.numitems >= 2) {
|
do {
|
||||||
while (--item >= 0) {
|
while (--item >= 0) {
|
||||||
const Fl_Menu_Item* m1 = m.menu->next(item);
|
const Fl_Menu_Item* m1 = m.menu->next(item);
|
||||||
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
if (m1->activevisible()) {setitem(m1, menu, item); return 1;}
|
||||||
}
|
}
|
||||||
item = m.numitems;
|
item = m.numitems;
|
||||||
}
|
}
|
||||||
|
while (pp.menubar && (!m.menu || m.menu->submenu()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user