[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSMenuView patch
From: |
Christopher Armstrong |
Subject: |
NSMenuView patch |
Date: |
Thu, 17 Feb 2011 22:39:10 +1100 |
I've reposted this here because I don't believe patches show up on the mailing
lists.
I've attached a patch at savannah that fixes some outside mouse behaviour
issues with Mac and Windows style menus. Specifically:
* Clicking outside the attached menu window to close it doesn't close the menu
* Moving the mouse outside the menu in Windows mode closes the menu
* Attached sub-menus in Windows mode stay open until another top-level menu is
selected, instead of disappearing when the mouse is moved outside the attached
sub-menu
https://savannah.gnu.org/patch/?7470
Cheers
Christopher Armstrong
address@hidden
--
Index: Source/NSMenuView.m
===================================================================
--- Source/NSMenuView.m (revision 32140)
+++ Source/NSMenuView.m (working copy)
@@ -1439,7 +1439,6 @@
int delayCount = 0;
int indexOfActionToExecute = -1;
int firstIndex = -1;
- int space = 0;
NSEvent *original;
NSEventType type;
NSEventType end;
@@ -1487,7 +1486,6 @@
eventMask |= NSLeftMouseUpMask | NSLeftMouseDraggedMask;
eventMask |= NSLeftMouseDownMask;
}
-
/* We attempt to mimic Mac OS X behavior for pop up menus. If the user
presses the mouse button over a pop up button and then drags the mouse
over the menu, the is closed when the user releases the mouse. On the
@@ -1503,6 +1501,11 @@
*/
shouldFinish = NO;
}
+
+ // Capture the mouse so we get clicks outside the menus and
+ // GNUstep windows.
+ [_window _captureMouse: self];
+
do
{
/*Close the menu if the user press a modifier key and menu
@@ -1512,6 +1515,7 @@
{
[self setHighlightedItemIndex: -1];
[[[[NSApp mainWindow] menu] attachedMenu] close];
+ [_window _releaseMouse: self];
return NO;
}
@@ -1585,7 +1589,6 @@
NSPoint locationInScreenCoordinates;
NSWindow *windowUnderMouse;
NSMenu *candidateMenu;
- NSMenu *anAttachedMenu = [[[NSApp mainWindow] menu] attachedMenu];
subMenusNeedRemoving = NO;
@@ -1631,6 +1634,7 @@
candidateMenuResult = [[candidateMenu menuRepresentation]
trackWithEvent: original];
+ [_window _releaseMouse: self];
return candidateMenuResult;
}
@@ -1650,6 +1654,7 @@
{
[self detachSubmenu];
}
+ [_window _releaseMouse: self];
return subMenuResult;
}
@@ -1660,23 +1665,16 @@
![[self menu] isTransient] &&
![[self menu] _ownedByPopUp])
{
- if ([self hitTest: location] == nil)
+ // If the user moves the mouse into the main window
+ // horizontal menu, start tracking again.
+ NSWindow *mainWindow = [NSApp mainWindow];
+ NSPoint locationInMainWindow = [mainWindow
+ convertScreenToBase: locationInScreenCoordinates];
+ if ([[[mainWindow menu] menuRepresentation]
+ hitTest: locationInMainWindow] != nil)
{
- /*This gives us time to move the cursor between a menu and
- its submenu (or vice versa) without lose the mouse
- tracking*/
- space += 1;
-
- if (space == 2)
- {
- [anAttachedMenu close];
- return NO;
- }
- }
-
- if (self != [[[NSApp mainWindow] menu] menuRepresentation])
- {
[self setHighlightedItemIndex: -1];
+ [_window _releaseMouse: self];
return [[[[NSApp mainWindow] menu] menuRepresentation]
trackWithEvent: original];
}
@@ -1711,6 +1709,9 @@
}
while (type != end || shouldFinish == NO);
+ // Uncapture the mouse again.
+ [_window _releaseMouse: self];
+
/*
* Ok, we released the mouse
* There are now a few possibilities:
- NSMenuView patch,
Christopher Armstrong <=
- Re: NSMenuView patch, Christopher Armstrong, 2011/02/18
- Re: NSMenuView patch, Germán Arias, 2011/02/18
- Re: NSMenuView patch, Christopher Armstrong, 2011/02/18
- Re: NSMenuView patch, Germán Arias, 2011/02/19
- Re: NSMenuView patch, Fred Kiefer, 2011/02/19
- Re: NSMenuView patch, Christopher Armstrong, 2011/02/19
- Re: NSMenuView patch, Quentin Mathé, 2011/02/21
- Re: NSMenuView patch, Wolfgang Lux, 2011/02/20
- Re: NSMenuView patch, Christopher Armstrong, 2011/02/20