Switched back to the GetMouse variation which does NOT check the message

queue, should fix bug 594 and not risk of losing clicks. SetStickyMode() 
calls StealFocus() to give the chance to be keyboard-navigated to menus. 
Added an extra (temporary) InvalidateLayout() because some items weren't 
added in 
some cases (Tracker's attributes menu for example)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17599 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-05-26 18:13:38 +00:00
parent 73f99cd6ae
commit 03f2d7791e
2 changed files with 20 additions and 2 deletions

View File

@ -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<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 we are switching to sticky mode, propagate the status
// back to the super menu
if (on && fSuper != NULL)

View File

@ -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();
}