If a NULL menuitem was supplied to BMenu::_NextItem(), the function
would have returned the second item in place of the first. Also return NULL, not false, when there are no "next items". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24294 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2354,10 +2354,13 @@ BMenu::_NextItem(BMenuItem *item, bool forward) const
|
|||||||
{
|
{
|
||||||
// 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)
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
const int32 numItems = fItems.CountItems();
|
const int32 numItems = fItems.CountItems();
|
||||||
|
if (index < 0) {
|
||||||
|
if (forward)
|
||||||
|
index = -1;
|
||||||
|
else
|
||||||
|
index = numItems;
|
||||||
|
}
|
||||||
int32 startIndex = index;
|
int32 startIndex = index;
|
||||||
do {
|
do {
|
||||||
if (forward)
|
if (forward)
|
||||||
@@ -2373,7 +2376,7 @@ BMenu::_NextItem(BMenuItem *item, bool forward) const
|
|||||||
} while (!ItemAt(index)->IsEnabled() && index != startIndex);
|
} while (!ItemAt(index)->IsEnabled() && index != startIndex);
|
||||||
|
|
||||||
if (index == startIndex) // we are back where we started and no item was enabled
|
if (index == startIndex) // we are back where we started and no item was enabled
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
return ItemAt(index);
|
return ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user