From 6e11b3f991eb4594914ae0a40b9b52e5887a775f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 11 Jan 2008 12:08:21 +0000 Subject: [PATCH] Close the whole menu hierarchy when invoking an item via keyboard. Added a TODO comment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23389 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Menu.h | 2 +- src/kits/interface/Menu.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index eb1d214e84..ccb11ccbb4 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -234,7 +234,7 @@ private: // private methods called by BWindow int State(BMenuItem** _item = NULL) const; void InvokeItem(BMenuItem* item, bool now = false); - void QuitTracking(); + void QuitTracking(bool onlyThis = true); static menu_info sMenuInfo; static bool sAltAsCommandKey; diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index e9994495fb..49e228199c 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -868,8 +868,10 @@ BMenu::KeyDown(const char *bytes, int32 numBytes) case B_ENTER: case B_SPACE: - if (fSelected) + if (fSelected) { InvokeItem(fSelected); + QuitTracking(false); + } break; case B_ESCAPE: @@ -1974,6 +1976,8 @@ BMenu::InvokeItem(BMenuItem *item, bool now) return; // Do the "selected" animation + // TODO: Doesn't work. This is supposed to highlight + // and dehighlight the item, works on beos but not on haiku. if (!item->Submenu() && LockLooper()) { snooze(50000); item->Select(true); @@ -2379,15 +2383,19 @@ BMenu::_CustomTrackingWantsToQuit() void -BMenu::QuitTracking() +BMenu::QuitTracking(bool onlyThis) { _SelectItem(NULL); if (BMenuBar *menuBar = dynamic_cast(this)) menuBar->_RestoreFocus(); fChosenItem = NULL; - fState = MENU_STATE_CLOSED; + + // Close the whole menu hierarchy + if (!onlyThis && _IsStickyMode()) + _SetStickyMode(false); + _Hide(); }