- 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)
{
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,9 +2067,6 @@ BMenu::OkToProceed(BMenuItem* item)
void
BMenu::QuitTracking()
{
if (IsStickyMode())
SetStickyMode(false);
if (fSelected != NULL)
SelectItem(NULL);
if (BMenuBar *menuBar = dynamic_cast<BMenuBar *>(this))
menuBar->RestoreFocus();

View File

@ -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) {
@ -451,6 +451,9 @@ 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);
}