Make pop-up menu behavior more like BeOS (though this still is not ideal):

If the menu opens right under the mouse cursor, do not select or invoke an item
until the mouse is moved. Since this seems to break normal menu bars, I added
the check for fSuper. As a (bad?) side effect BMenuField menus also need mouse
movement before something is selected. If anything else is broken, let me know.

I'm committing this because it does remove some bad behavior in pop up menus
(unintentionally selecting items.)

We may also want to force the openAnyway behavior as discussed on the mailing
list in December.

In general though the menu handling code really should be redesigned/refactored.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2011-01-06 07:14:47 +00:00
parent 2b70c8f3e4
commit f8f64f9a2e
+15 -2
View File
@@ -1563,9 +1563,20 @@ BMenu::_Track(int* action, long start)
fSuper->fState = MENU_STATE_TRACKING_SUBMENU;
BPoint location;
BPoint screenLocation;
uint32 buttons = 0;
bool openedUnderMouse = false;
if (LockLooper()) {
GetMouse(&location, &buttons);
// If the menu has opened underneath the mouse we will not invoke or return
// the selected item unless the mouse is moved. This only applies if there
// is no parent menu.
if (fSuper == NULL) {
screenLocation = ConvertToScreen(location);
openedUnderMouse = Window()->Frame().Contains(screenLocation);
}
UnlockLooper();
}
@@ -1578,7 +1589,7 @@ BMenu::_Track(int* action, long start)
break;
BMenuWindow* window = static_cast<BMenuWindow*>(Window());
BPoint screenLocation = ConvertToScreen(location);
screenLocation = ConvertToScreen(location);
if (window->CheckForScrolling(screenLocation)) {
UnlockLooper();
continue;
@@ -1590,7 +1601,8 @@ BMenu::_Track(int* action, long start)
// then if the menu is inside this menu,
// then if it's over a super menu.
bool overSub = _OverSubmenu(fSelected, screenLocation);
item = _HitTestItems(location, B_ORIGIN);
if (!openedUnderMouse)
item = _HitTestItems(location, B_ORIGIN);
if (overSub) {
navAreaRectAbove = BRect();
navAreaRectBelow = BRect();
@@ -1670,6 +1682,7 @@ BMenu::_Track(int* action, long start)
releasedOnce = true;
location = newLocation;
buttons = newButtons;
openedUnderMouse = false;
}
if (releasedOnce)