Don't invoke the highlighted item if menu was closed using the ESC key

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18560 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2006-08-22 09:04:21 +00:00
parent 136869d8c0
commit 0adbde4a9e
+8 -7
View File
@@ -389,7 +389,8 @@ BMenuItem *
BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
{ {
// TODO: Cleanup, merge some "if" blocks if possible // TODO: Cleanup, merge some "if" blocks if possible
BMenuItem *resultItem = NULL; fChosenItem = NULL;
BWindow *window = Window(); BWindow *window = Window();
fState = MENU_STATE_TRACKING; fState = MENU_STATE_TRACKING;
@@ -429,7 +430,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
// Menu was already opened, close it and bail // Menu was already opened, close it and bail
SelectItem(NULL); SelectItem(NULL);
fState = MENU_STATE_CLOSED; fState = MENU_STATE_CLOSED;
resultItem = NULL; fChosenItem = NULL;
} }
} else { } else {
// No submenu, just select the item // No submenu, just select the item
@@ -449,7 +450,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (IsStickyMode()) if (IsStickyMode())
menu->SetStickyMode(true); menu->SetStickyMode(true);
int localAction; int localAction;
resultItem = menu->_track(&localAction, system_time()); fChosenItem = menu->_track(&localAction, system_time());
//menu->Window()->Activate(); //menu->Window()->Activate();
if (localAction == MENU_STATE_CLOSED) if (localAction == MENU_STATE_CLOSED)
fState = MENU_STATE_CLOSED; fState = MENU_STATE_CLOSED;
@@ -468,7 +469,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
break; break;
else if (buttons == 0 && !IsStickyMode()) { else if (buttons == 0 && !IsStickyMode()) {
if ((fSelected != NULL && fSelected->Submenu() == NULL) || menuItem == NULL) { if ((fSelected != NULL && fSelected->Submenu() == NULL) || menuItem == NULL) {
resultItem = fSelected; fChosenItem = fSelected;
break; break;
} else } else
SetStickyMode(true); SetStickyMode(true);
@@ -481,8 +482,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (window->Lock()) { if (window->Lock()) {
if (fSelected != NULL) if (fSelected != NULL)
SelectItem(NULL); SelectItem(NULL);
if (resultItem != NULL) if (fChosenItem != NULL)
resultItem->Invoke(); fChosenItem->Invoke();
RestoreFocus(); RestoreFocus();
window->Unlock(); window->Unlock();
} }
@@ -495,7 +496,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (action != NULL) if (action != NULL)
*action = fState; *action = fState;
return resultItem; return fChosenItem;
} }