[haiku-commits] Re: r40132 - haiku/trunk/src/kits/interface

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-commits@xxxxxxxxxxxxx" <haiku-commits@xxxxxxxxxxxxx>
  • Date: Thu, 6 Jan 2011 03:53:03 -0500


On Jan 6, 2011, at 2:14 AM, leavengood@xxxxxxxxx wrote:

Author: leavengood
Date: 2011-01-06 08:14:47 +0100 (Thu, 06 Jan 2011)
New Revision: 40132
Changeset: http://dev.haiku-os.org/changeset/40132

Modified:
  haiku/trunk/src/kits/interface/Menu.cpp
Log:
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.)

I checked BeOS R5. If you right click an app with a popup menu such as Magnify and the mouse appears over the popup menu because the popup menu is too close to the right side of a screen to draw to the right of the mouse pointer than the menu will stay up after you release the right mouse button until a left click is issued to select an item or the mouse leaves the pop up menu. However you are not required to move the mouse before making a selection. You can choose to select the item directly under the mouse by left clicking on the menu item without moving the mouse so this fix (at least how I understand from your description) does not accuratly emulate the BeOS popup menu behavior.

I think that emulating BeOS's (rather strange IMHO) behavior is not right in this situation. Other OS's solve this problem by always drawing the menu outside of the mouse pointer. If there is not enough room to the right of the mouse pointer than the menu is drawn to the left instead. Same with top/bottom. I think that is better solution.


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

I agree. I like this behavior better. The current behavior is a relic from MacOS 7 that even Apple abandoned in MacOS 8. Keep the menu open after the right click is released allowing you to view the menu options and then select one with a left click should be the default. Right click and hold, drag to the menu item you want and then release to select is a useful shortcut and should (and is with Travis' patch) be kept but should not be the default behavior.


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


Modified: haiku/trunk/src/kits/interface/Menu.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Menu.cpp 2011-01-06 03:57:58 UTC (rev 40131) +++ haiku/trunk/src/kits/interface/Menu.cpp 2011-01-06 07:14:47 UTC (rev 40132)
@@ -1563,9 +1563,20 @@
       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 @@
           break;

       BMenuWindow* window = static_cast<BMenuWindow*>(Window());
-        BPoint screenLocation = ConvertToScreen(location);
+        screenLocation = ConvertToScreen(location);
       if (window->CheckForScrolling(screenLocation)) {
           UnlockLooper();
           continue;
@@ -1590,7 +1601,8 @@
       // 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 @@
                   releasedOnce = true;
               location = newLocation;
               buttons = newButtons;
+                openedUnderMouse = false;
           }

           if (releasedOnce)



Other related posts: