mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 08:51:57 +00:00
* Source/NSMenuView.m: Refactor code which executes the action
of a menu item at a given index into a separate method to make it easier to override this behavior when necessary. Added method _executeItemAtIndex:removeSubmenu:. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27680 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
89591acc3f
commit
771bce4672
2 changed files with 82 additions and 64 deletions
|
@ -1,3 +1,10 @@
|
|||
2009-01-25 06:47-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSMenuView.m: Refactor code which executes the action
|
||||
of a menu item at a given index into a separate method to make it
|
||||
easier to override this behavior when necessary. Added method
|
||||
_executeItemAtIndex:removeSubmenu:.
|
||||
|
||||
2009-01-25 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* TextConverters/RTF/RTFProducer.m (RTFDProducer -produceFileFrom:...):
|
||||
|
|
|
@ -1278,6 +1278,57 @@ static NSMapTable *viewInfo = 0;
|
|||
#define MOVE_THRESHOLD_DELTA 2.0
|
||||
#define DELAY_MULTIPLIER 10
|
||||
|
||||
- (BOOL) _executeItemAtIndex: (int)indexOfActionToExecute
|
||||
removeSubmenu: (BOOL)subMenusNeedRemoving
|
||||
{
|
||||
if (indexOfActionToExecute == -1)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (indexOfActionToExecute >= 0
|
||||
&& [_attachedMenu attachedMenu] != nil && [_attachedMenu attachedMenu] ==
|
||||
[[_items_link objectAtIndex: indexOfActionToExecute] submenu])
|
||||
{
|
||||
#if 1
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||
== NSMacintoshInterfaceStyle)
|
||||
{
|
||||
/*
|
||||
* FIXME ... always remove submenus in mac mode ... this is not
|
||||
* quite the way the mac behaves, but it's closer than the normal
|
||||
* behavior.
|
||||
*/
|
||||
subMenusNeedRemoving = YES;
|
||||
}
|
||||
#endif
|
||||
if (subMenusNeedRemoving)
|
||||
{
|
||||
[self detachSubmenu];
|
||||
}
|
||||
// Clicked on a submenu.
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||
== NSMacintoshInterfaceStyle)
|
||||
{
|
||||
NSMenu *tmp = _attachedMenu;
|
||||
|
||||
do
|
||||
{
|
||||
if ([tmp isEqual: [NSApp mainMenu]] == NO)
|
||||
{
|
||||
[tmp close];
|
||||
}
|
||||
tmp = [tmp supermenu];
|
||||
}
|
||||
while (tmp != nil);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) trackWithEvent: (NSEvent*)event
|
||||
{
|
||||
unsigned eventMask = NSPeriodicMask;
|
||||
|
@ -1559,52 +1610,12 @@ static NSMapTable *viewInfo = 0;
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
if (indexOfActionToExecute == -1)
|
||||
if([self _executeItemAtIndex: indexOfActionToExecute
|
||||
removeSubmenu: subMenusNeedRemoving] == NO)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (indexOfActionToExecute >= 0
|
||||
&& [_attachedMenu attachedMenu] != nil && [_attachedMenu attachedMenu] ==
|
||||
[[_items_link objectAtIndex: indexOfActionToExecute] submenu])
|
||||
{
|
||||
#if 1
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||
== NSMacintoshInterfaceStyle)
|
||||
{
|
||||
/*
|
||||
* FIXME ... always remove submenus in mac mode ... this is not
|
||||
* quite the way the mac behaves, but it's closer than the normal
|
||||
* behavior.
|
||||
*/
|
||||
subMenusNeedRemoving = YES;
|
||||
}
|
||||
#endif
|
||||
if (subMenusNeedRemoving)
|
||||
{
|
||||
[self detachSubmenu];
|
||||
}
|
||||
// Clicked on a submenu.
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||
== NSMacintoshInterfaceStyle)
|
||||
{
|
||||
NSMenu *tmp = _attachedMenu;
|
||||
|
||||
do
|
||||
{
|
||||
if ([tmp isEqual: [NSApp mainMenu]] == NO)
|
||||
{
|
||||
[tmp close];
|
||||
}
|
||||
tmp = [tmp supermenu];
|
||||
}
|
||||
while (tmp != nil);
|
||||
}
|
||||
|
||||
[_attachedMenu performActionForItemAtIndex: indexOfActionToExecute];
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue