- 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
This commit is contained in:
Stefano Ceccherini 2006-05-30 19:14:54 +00:00
parent f428e7ad4a
commit b9af5bfa5c
2 changed files with 14 additions and 13 deletions

View File

@ -741,7 +741,7 @@ void
BMenu::KeyDown(const char *bytes, int32 numBytes) BMenu::KeyDown(const char *bytes, int32 numBytes)
{ {
switch (bytes[0]) { switch (bytes[0]) {
case B_UP_ARROW: /*case B_UP_ARROW:
{ {
if (fSelected) { if (fSelected) {
fSelected->fSelected = false; fSelected->fSelected = false;
@ -801,6 +801,11 @@ BMenu::KeyDown(const char *bytes, int32 numBytes)
break; break;
} }
*/
case B_ESCAPE:
QuitTracking();
break;
default: default:
BView::KeyDown(bytes, numBytes); BView::KeyDown(bytes, numBytes);
} }
@ -1240,8 +1245,7 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
bigtime_t snoozeAmount = 50000; bigtime_t snoozeAmount = 50000;
BPoint location; BPoint location;
ulong buttons; ulong buttons;
GetMouse(&location, &buttons, false); GetMouse(&location, &buttons, true);
// Get the current mouse state
Window()->UpdateIfNeeded(); Window()->UpdateIfNeeded();
BPoint screenLocation = ConvertToScreen(location); BPoint screenLocation = ConvertToScreen(location);
@ -2063,9 +2067,6 @@ BMenu::OkToProceed(BMenuItem* item)
void void
BMenu::QuitTracking() BMenu::QuitTracking()
{ {
if (IsStickyMode())
SetStickyMode(false);
if (fSelected != NULL)
SelectItem(NULL); SelectItem(NULL);
if (BMenuBar *menuBar = dynamic_cast<BMenuBar *>(this)) if (BMenuBar *menuBar = dynamic_cast<BMenuBar *>(this))
menuBar->RestoreFocus(); menuBar->RestoreFocus();

View File

@ -400,8 +400,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
BPoint where; BPoint where;
ulong buttons; ulong buttons;
GetMouse(&where, &buttons, false); GetMouse(&where, &buttons, true);
// Get the current mouse state
window->UpdateIfNeeded(); window->UpdateIfNeeded();
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
if (menuItem != NULL) { if (menuItem != NULL) {
@ -451,6 +451,9 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (locked) if (locked)
window->Unlock(); window->Unlock();
if (fState == MENU_STATE_CLOSED)
break;
if (localAction == MENU_STATE_CLOSED || (buttons != 0 && IsStickyMode() && menuItem == NULL)) if (localAction == MENU_STATE_CLOSED || (buttons != 0 && IsStickyMode() && menuItem == NULL))
break; break;
else if (buttons == 0 && !IsStickyMode()) { else if (buttons == 0 && !IsStickyMode()) {
@ -462,9 +465,6 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
SetStickyMode(true); SetStickyMode(true);
} }
if (fState == MENU_STATE_CLOSED)
break;
if (snoozeAmount > 0) if (snoozeAmount > 0)
snooze(snoozeAmount); snooze(snoozeAmount);
} }