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:
parent
cd39decc44
commit
c1dd282b9b
@ -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<BMenuBar *>(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<BMenuBar *>(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
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <MenuPrivate.h>
|
||||
#include <TokenSpace.h>
|
||||
|
||||
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<BView *>(handler);
|
||||
if (view != NULL && view->Window() == window)
|
||||
view->MakeFocus();
|
||||
}
|
||||
fPrevFocusToken = -1;
|
||||
fPrevFocusToken = -1;
|
||||
|
||||
} else if (IsFocus())
|
||||
MakeFocus(false);
|
||||
|
||||
window->Unlock();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user