From 0adbde4a9e3e516bd62ab1f4b8cda6086294aa9f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 22 Aug 2006 09:04:21 +0000 Subject: [PATCH] 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 --- src/kits/interface/MenuBar.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index ec1b39afed..95e4dc73e7 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -389,7 +389,8 @@ BMenuItem * BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) { // TODO: Cleanup, merge some "if" blocks if possible - BMenuItem *resultItem = NULL; + fChosenItem = NULL; + BWindow *window = Window(); fState = MENU_STATE_TRACKING; @@ -429,7 +430,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) // Menu was already opened, close it and bail SelectItem(NULL); fState = MENU_STATE_CLOSED; - resultItem = NULL; + fChosenItem = NULL; } } else { // No submenu, just select the item @@ -449,7 +450,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) if (IsStickyMode()) menu->SetStickyMode(true); int localAction; - resultItem = menu->_track(&localAction, system_time()); + fChosenItem = menu->_track(&localAction, system_time()); //menu->Window()->Activate(); if (localAction == MENU_STATE_CLOSED) fState = MENU_STATE_CLOSED; @@ -468,7 +469,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) break; else if (buttons == 0 && !IsStickyMode()) { if ((fSelected != NULL && fSelected->Submenu() == NULL) || menuItem == NULL) { - resultItem = fSelected; + fChosenItem = fSelected; break; } else SetStickyMode(true); @@ -481,8 +482,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) if (window->Lock()) { if (fSelected != NULL) SelectItem(NULL); - if (resultItem != NULL) - resultItem->Invoke(); + if (fChosenItem != NULL) + fChosenItem->Invoke(); RestoreFocus(); window->Unlock(); } @@ -495,7 +496,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) if (action != NULL) *action = fState; - return resultItem; + return fChosenItem; }