diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index a5cf6edfb6..e860dc2b37 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1931,15 +1931,17 @@ BMenu::SetIgnoreHidden(bool on) void 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 (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(); + } + + fStickyMode = on; } // If we are switching to sticky mode, propagate the status diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index abe0d69211..b0103d754a 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -17,6 +17,7 @@ #include #include +using BPrivate::gDefaultTokens; struct menubar_data { BMenuBar *menuBar; @@ -509,13 +510,16 @@ BMenuBar::RestoreFocus() BWindow *window = Window(); if (window != NULL && window->Lock()) { BHandler *handler = NULL; - if (BPrivate::gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, - (void **)&handler) == B_OK) { + if (fPrevFocusToken != -1 + && gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, (void **)&handler) == B_OK) { BView *view = dynamic_cast(handler); if (view != NULL && view->Window() == window) view->MakeFocus(); - } - fPrevFocusToken = -1; + fPrevFocusToken = -1; + + } else if (IsFocus()) + MakeFocus(false); + window->Unlock(); } }