fixed a few problems in BMenuBar, triggered by the particular use the
Menu preflet makes of it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24006 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -464,7 +464,7 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fState != MENU_STATE_CLOSED) {
|
while (fState != MENU_STATE_CLOSED) {
|
||||||
bigtime_t snoozeAmount = 40000;
|
bigtime_t snoozeAmount = 40000;
|
||||||
if (Window() == NULL || !window->Lock())
|
if (Window() == NULL || !window->Lock())
|
||||||
@@ -472,29 +472,19 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
|
|
||||||
BMenuItem *menuItem = _HitTestItems(where, B_ORIGIN);
|
BMenuItem *menuItem = _HitTestItems(where, B_ORIGIN);
|
||||||
if (menuItem != NULL) {
|
if (menuItem != NULL) {
|
||||||
// Select item if:
|
if (menuItem->Submenu() != NULL && menuItem != fSelected) {
|
||||||
// - no previous selection
|
if (menuItem->Submenu()->Window() == NULL) {
|
||||||
// - nonsticky mode and different selection,
|
// open the menu if it's not opened yet
|
||||||
// - clicked in sticky mode
|
_SelectItem(menuItem);
|
||||||
if (fSelected == NULL
|
|
||||||
|| (menuItem != fSelected)
|
|
||||||
|| (buttons != 0 && _IsStickyMode())) {
|
|
||||||
if (menuItem->Submenu() != NULL) {
|
|
||||||
if (menuItem->Submenu()->Window() == NULL) {
|
|
||||||
// open the menu if it's not opened yet
|
|
||||||
_SelectItem(menuItem);
|
|
||||||
if (_IsStickyMode())
|
|
||||||
_SetStickyMode(false);
|
|
||||||
} else {
|
|
||||||
// Menu was already opened, close it and bail
|
|
||||||
_SelectItem(NULL);
|
|
||||||
fState = MENU_STATE_CLOSED;
|
|
||||||
fChosenItem = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// No submenu, just select the item
|
// Menu was already opened, close it and bail
|
||||||
_SelectItem(menuItem);
|
_SelectItem(NULL);
|
||||||
|
fState = MENU_STATE_CLOSED;
|
||||||
|
fChosenItem = NULL;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// No submenu, just select the item
|
||||||
|
_SelectItem(menuItem);
|
||||||
}
|
}
|
||||||
} else if (_OverSubmenu(fSelected, ConvertToScreen(where))) {
|
} else if (_OverSubmenu(fSelected, ConvertToScreen(where))) {
|
||||||
// call _Track() from the selected sub-menu when the mouse cursor
|
// call _Track() from the selected sub-menu when the mouse cursor
|
||||||
@@ -550,9 +540,12 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buttons != 0 && _IsStickyMode() && menuItem == NULL))
|
if (buttons != 0 && _IsStickyMode()) {
|
||||||
fState = MENU_STATE_CLOSED;
|
if (menuItem == NULL)
|
||||||
else if (buttons == 0 && !_IsStickyMode()) {
|
fState = MENU_STATE_CLOSED;
|
||||||
|
else
|
||||||
|
_SetStickyMode(false);
|
||||||
|
} else if (buttons == 0 && !_IsStickyMode()) {
|
||||||
if ((fSelected != NULL && fSelected->Submenu() == NULL)
|
if ((fSelected != NULL && fSelected->Submenu() == NULL)
|
||||||
|| menuItem == NULL) {
|
|| menuItem == NULL) {
|
||||||
fChosenItem = fSelected;
|
fChosenItem = fSelected;
|
||||||
@@ -562,7 +555,7 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->Lock()) {
|
if (window->Lock()) {
|
||||||
if (fSelected != NULL)
|
if (fSelected != NULL)
|
||||||
_SelectItem(NULL);
|
_SelectItem(NULL);
|
||||||
@@ -582,6 +575,7 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
*action = fState;
|
*action = fState;
|
||||||
|
|
||||||
return fChosenItem;
|
return fChosenItem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user