From b9af5bfa5c018d4d53252750943ae5e16da562d5 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 30 May 2006 19:14:54 +0000 Subject: [PATCH] - Fixed the recently introduced bug where menus would open again once closed. -Now hitting ESC will close the menu. - Reverted to the other variation of GetMouse() as Axel's advice git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17654 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 15 ++++++++------- src/kits/interface/MenuBar.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 958a125cd7..441f607984 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -741,7 +741,7 @@ void BMenu::KeyDown(const char *bytes, int32 numBytes) { switch (bytes[0]) { - case B_UP_ARROW: + /*case B_UP_ARROW: { if (fSelected) { fSelected->fSelected = false; @@ -801,6 +801,11 @@ BMenu::KeyDown(const char *bytes, int32 numBytes) break; } + */ + case B_ESCAPE: + QuitTracking(); + break; + default: BView::KeyDown(bytes, numBytes); } @@ -1240,8 +1245,7 @@ BMenu::_track(int *action, bigtime_t trackTime, long start) bigtime_t snoozeAmount = 50000; BPoint location; ulong buttons; - GetMouse(&location, &buttons, false); - // Get the current mouse state + GetMouse(&location, &buttons, true); Window()->UpdateIfNeeded(); BPoint screenLocation = ConvertToScreen(location); @@ -2063,10 +2067,7 @@ BMenu::OkToProceed(BMenuItem* item) void BMenu::QuitTracking() { - if (IsStickyMode()) - SetStickyMode(false); - if (fSelected != NULL) - SelectItem(NULL); + SelectItem(NULL); if (BMenuBar *menuBar = dynamic_cast(this)) menuBar->RestoreFocus(); diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index b0103d754a..9528fc9880 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -400,8 +400,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) BPoint where; ulong buttons; - GetMouse(&where, &buttons, false); - // Get the current mouse state + GetMouse(&where, &buttons, true); + window->UpdateIfNeeded(); BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); if (menuItem != NULL) { @@ -450,7 +450,10 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) if (locked) window->Unlock(); - + + if (fState == MENU_STATE_CLOSED) + break; + if (localAction == MENU_STATE_CLOSED || (buttons != 0 && IsStickyMode() && menuItem == NULL)) break; else if (buttons == 0 && !IsStickyMode()) { @@ -462,9 +465,6 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) SetStickyMode(true); } - if (fState == MENU_STATE_CLOSED) - break; - if (snoozeAmount > 0) snooze(snoozeAmount); }