BMenu::_SelectNextItem() also opens the menu if we're inside a menubar.
That way menubars are navigable via keyboard. There are still glitches, but menu keyboard navigation works now. Minor optimization: cache the value of CountItems() instead of calling it multiple times. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23387 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2159,7 +2159,10 @@ BMenu::_SelectNextItem(BMenuItem *item, bool forward)
|
|||||||
if (nextItem == NULL)
|
if (nextItem == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_SelectItem(nextItem, false);
|
bool openMenu = false;
|
||||||
|
if (dynamic_cast<BMenuBar *>(this) != NULL)
|
||||||
|
openMenu = true;
|
||||||
|
_SelectItem(nextItem, openMenu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2167,18 +2170,12 @@ BMenu::_SelectNextItem(BMenuItem *item, bool forward)
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::_NextItem(BMenuItem *item, bool forward) const
|
BMenu::_NextItem(BMenuItem *item, bool forward) const
|
||||||
{
|
{
|
||||||
/*if (item == NULL) {
|
|
||||||
if (forward)
|
|
||||||
return ItemAt(CountItems() - 1);
|
|
||||||
|
|
||||||
return ItemAt(0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// go to next item, and skip over disabled items such as separators
|
// go to next item, and skip over disabled items such as separators
|
||||||
int32 index = fItems.IndexOf(item);
|
int32 index = fItems.IndexOf(item);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
|
const int32 numItems = fItems.CountItems();
|
||||||
int32 startIndex = index;
|
int32 startIndex = index;
|
||||||
do {
|
do {
|
||||||
if (forward)
|
if (forward)
|
||||||
@@ -2188,8 +2185,8 @@ BMenu::_NextItem(BMenuItem *item, bool forward) const
|
|||||||
|
|
||||||
// cycle through menu items
|
// cycle through menu items
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = CountItems() - 1;
|
index = numItems - 1;
|
||||||
else if(index >= fItems.CountItems())
|
else if (index >= numItems)
|
||||||
index = 0;
|
index = 0;
|
||||||
} while (!ItemAt(index)->IsEnabled() && index != startIndex);
|
} while (!ItemAt(index)->IsEnabled() && index != startIndex);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user