From 5c30ed357ad2a7a558d3a0171e0a017616969cee Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 7 Mar 2008 21:00:46 +0000 Subject: [PATCH] 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 --- src/kits/interface/Menu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 08293d773a..1e6563a763 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2354,10 +2354,13 @@ BMenu::_NextItem(BMenuItem *item, bool forward) const { // go to next item, and skip over disabled items such as separators int32 index = fItems.IndexOf(item); - if (index < 0) - index = 0; - const int32 numItems = fItems.CountItems(); + if (index < 0) { + if (forward) + index = -1; + else + index = numItems; + } int32 startIndex = index; do { if (forward) @@ -2373,7 +2376,7 @@ BMenu::_NextItem(BMenuItem *item, bool forward) const } while (!ItemAt(index)->IsEnabled() && index != startIndex); if (index == startIndex) // we are back where we started and no item was enabled - return false; + return NULL; return ItemAt(index); }