diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index ade824145b..e2c93f6774 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1236,8 +1236,10 @@ BMenu::_track(int *action, bigtime_t trackTime, long start) bigtime_t snoozeAmount = 50000; BPoint location; ulong buttons; - GetMouse(&location, &buttons, true); + GetMouse(&location, &buttons, false); + // Get the current mouse state + Window()->UpdateIfNeeded(); BPoint screenLocation = ConvertToScreen(location); item = HitTestItems(location, B_ORIGIN); if (item != NULL) { @@ -1356,6 +1358,10 @@ BMenu::_AddItem(BMenuItem *item, int32 index) item->SetSuper(this); + // TODO: Sometimes the menu layout isn't invalidated correctly, + // So we force a rebuild of the whole menu layout. Remove this! + InvalidateLayout(); + return true; } @@ -1927,6 +1933,15 @@ BMenu::SetStickyMode(bool on) { fStickyMode = on; + // TODO: Ugly hack, but it needs to be done right here in this method + BMenuBar *menuBar = dynamic_cast(this); + if (on && menuBar != NULL && menuBar->LockLooper()) { + // Steal the focus from the current focus view + // (needed to handle keyboard navigation) + menuBar->StealFocus(); + menuBar->UnlockLooper(); + } + // If we are switching to sticky mode, propagate the status // back to the super menu if (on && fSuper != NULL) diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 997124e9b2..29f92290f4 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -399,7 +399,9 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) BPoint where; ulong buttons; - GetMouse(&where, &buttons, true); + GetMouse(&where, &buttons, false); + // Get the current mouse state + window->UpdateIfNeeded(); BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); if (menuItem != NULL) { // Select item if: @@ -468,6 +470,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu) SelectItem(NULL); if (resultItem != NULL) resultItem->Invoke(); + RestoreFocus(); window->Unlock(); }