From b7d5dadaddd448ef7cc96af20b4998ee46f0fdb4 Mon Sep 17 00:00:00 2001 From: espectador Date: Fri, 7 Jan 2011 05:27:29 +0000 Subject: [PATCH] Fixed the tracking of mouse at horizontal menu git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31844 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSMenuView.m | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cabc0d7aa..6e85a6966 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-06 German Arias + + * Source/NSMenuView.m (-locationForSubmenu:, -trackWithEvent:): + Fixed the tracking of mouse at horizontal menu. + 2011-01-04 Doug Simons * Source/NSSearchFieldCell.m: diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index b2fed3a49..c330461a4 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -1071,7 +1071,9 @@ static NSMapTable *viewInfo = 0; [_attachedMenu indexOfItemWithSubmenu: aSubmenu]] toView: nil]; NSPoint subOrigin = [_window convertBaseToScreen: aRect.origin]; - return NSMakePoint(subOrigin.x, subOrigin.y - NSHeight(submenuFrame)); + /*We add +1 for don't lose the track when the user move the + mouse from the horizontal menu to a submenu.*/ + return NSMakePoint(subOrigin.x, subOrigin.y - NSHeight(submenuFrame) + 1); } } @@ -1618,6 +1620,27 @@ static NSMapTable *viewInfo = 0; } return subMenuResult; } + + /*We track the menu correctly when this is located + in a window*/ + if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self) == + NSWindows95InterfaceStyle) + { + if ([self hitTest: location] == nil) + { + [[[[NSApp mainWindow] menu] attachedMenu] close]; + shouldFinish = YES; + return NO; + } + + if (self != [[[NSApp mainWindow] menu] menuRepresentation]) + { + [self setHighlightedItemIndex: -1]; + shouldFinish = YES; + return [[[[NSApp mainWindow] menu] menuRepresentation] + trackWithEvent: original]; + } + } } // 4 - We changed the selected item and should update.