Fixed some bugs in StealFocus, RemoveFocus and SetStickyMode
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17614 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1931,15 +1931,17 @@ BMenu::SetIgnoreHidden(bool on)
|
|||||||
void
|
void
|
||||||
BMenu::SetStickyMode(bool on)
|
BMenu::SetStickyMode(bool on)
|
||||||
{
|
{
|
||||||
fStickyMode = on;
|
if (fStickyMode != on) {
|
||||||
|
// TODO: Ugly hack, but it needs to be done right here in this method
|
||||||
// TODO: Ugly hack, but it needs to be done right here in this method
|
BMenuBar *menuBar = dynamic_cast<BMenuBar *>(this);
|
||||||
BMenuBar *menuBar = dynamic_cast<BMenuBar *>(this);
|
if (on && menuBar != NULL && menuBar->LockLooper()) {
|
||||||
if (on && menuBar != NULL && menuBar->LockLooper()) {
|
// Steal the focus from the current focus view
|
||||||
// Steal the focus from the current focus view
|
// (needed to handle keyboard navigation)
|
||||||
// (needed to handle keyboard navigation)
|
menuBar->StealFocus();
|
||||||
menuBar->StealFocus();
|
menuBar->UnlockLooper();
|
||||||
menuBar->UnlockLooper();
|
}
|
||||||
|
|
||||||
|
fStickyMode = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are switching to sticky mode, propagate the status
|
// If we are switching to sticky mode, propagate the status
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <MenuPrivate.h>
|
#include <MenuPrivate.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
|
|
||||||
|
using BPrivate::gDefaultTokens;
|
||||||
|
|
||||||
struct menubar_data {
|
struct menubar_data {
|
||||||
BMenuBar *menuBar;
|
BMenuBar *menuBar;
|
||||||
@@ -509,13 +510,16 @@ BMenuBar::RestoreFocus()
|
|||||||
BWindow *window = Window();
|
BWindow *window = Window();
|
||||||
if (window != NULL && window->Lock()) {
|
if (window != NULL && window->Lock()) {
|
||||||
BHandler *handler = NULL;
|
BHandler *handler = NULL;
|
||||||
if (BPrivate::gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN,
|
if (fPrevFocusToken != -1
|
||||||
(void **)&handler) == B_OK) {
|
&& gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, (void **)&handler) == B_OK) {
|
||||||
BView *view = dynamic_cast<BView *>(handler);
|
BView *view = dynamic_cast<BView *>(handler);
|
||||||
if (view != NULL && view->Window() == window)
|
if (view != NULL && view->Window() == window)
|
||||||
view->MakeFocus();
|
view->MakeFocus();
|
||||||
}
|
fPrevFocusToken = -1;
|
||||||
fPrevFocusToken = -1;
|
|
||||||
|
} else if (IsFocus())
|
||||||
|
MakeFocus(false);
|
||||||
|
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user