mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
protect changedMessagesEnabled flag; update menus after modal session, key or main window change
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29891 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8dd7827584
commit
ce29b8d726
3 changed files with 77 additions and 57 deletions
|
@ -1,3 +1,10 @@
|
|||
2005-03-09 Doug Simons <doug.simons@testplant.com>
|
||||
|
||||
* Source/NSMenu.m: Protect changedMessagesEnabled flag against getting
|
||||
stuck off if exceptions occur during update.
|
||||
* Source/NSApplication.m: Update menu after modal session, and when
|
||||
the key or main window has changed.
|
||||
|
||||
2005-03-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSAlert.m: Cope gracefully with being called from an non-gui
|
||||
|
|
|
@ -1696,6 +1696,10 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[_main_menu update];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3883,6 +3887,7 @@ struct _DelegateWrapper
|
|||
if (_key_window == nil && [obj isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
_key_window = obj;
|
||||
[_main_menu update];
|
||||
}
|
||||
else if (_key_window != obj)
|
||||
{
|
||||
|
@ -3897,6 +3902,7 @@ struct _DelegateWrapper
|
|||
if (_main_window == nil && [obj isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
_main_window = obj;
|
||||
[_main_menu update];
|
||||
}
|
||||
else if (_main_window != obj)
|
||||
{
|
||||
|
|
121
Source/NSMenu.m
121
Source/NSMenu.m
|
@ -1124,68 +1124,75 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
// Temporary disable automatic displaying of menu.
|
||||
[self setMenuChangedMessagesEnabled: NO];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSMenuItem *item = [_items objectAtIndex: i];
|
||||
SEL action = [item action];
|
||||
id validator = nil;
|
||||
BOOL wasEnabled = [item isEnabled];
|
||||
BOOL shouldBeEnabled;
|
||||
|
||||
// Update the submenu items if any.
|
||||
if ([item hasSubmenu])
|
||||
[[item submenu] update];
|
||||
|
||||
// If there is no action - there can be no validator for the item.
|
||||
if (action)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
validator = [NSApp targetForAction: action
|
||||
to: [item target]
|
||||
from: item];
|
||||
}
|
||||
else if (_popUpButtonCell != nil)
|
||||
{
|
||||
if (NULL != (action = [_popUpButtonCell action]))
|
||||
NSMenuItem *item = [_items objectAtIndex: i];
|
||||
SEL action = [item action];
|
||||
id validator = nil;
|
||||
BOOL wasEnabled = [item isEnabled];
|
||||
BOOL shouldBeEnabled;
|
||||
|
||||
// Update the submenu items if any.
|
||||
if ([item hasSubmenu])
|
||||
[[item submenu] update];
|
||||
|
||||
// If there is no action - there can be no validator for the item.
|
||||
if (action)
|
||||
{
|
||||
validator = [NSApp targetForAction: action
|
||||
to: [_popUpButtonCell target]
|
||||
from: [_popUpButtonCell controlView]];
|
||||
}
|
||||
}
|
||||
validator = [NSApp targetForAction: action
|
||||
to: [item target]
|
||||
from: item];
|
||||
}
|
||||
else if (_popUpButtonCell != nil)
|
||||
{
|
||||
if (NULL != (action = [_popUpButtonCell action]))
|
||||
{
|
||||
validator = [NSApp targetForAction: action
|
||||
to: [_popUpButtonCell target]
|
||||
from: [_popUpButtonCell controlView]];
|
||||
}
|
||||
}
|
||||
|
||||
if (validator == nil)
|
||||
{
|
||||
if ((action == NULL) && (_popUpButtonCell != nil))
|
||||
{
|
||||
shouldBeEnabled = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeEnabled = NO;
|
||||
}
|
||||
}
|
||||
else if ([validator
|
||||
respondsToSelector: @selector(validateMenuItem:)])
|
||||
{
|
||||
shouldBeEnabled = [validator validateMenuItem: item];
|
||||
}
|
||||
else if ([validator
|
||||
respondsToSelector: @selector(validateUserInterfaceItem:)])
|
||||
{
|
||||
shouldBeEnabled = [validator validateUserInterfaceItem: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeEnabled = YES;
|
||||
}
|
||||
if (validator == nil)
|
||||
{
|
||||
if ((action == NULL) && (_popUpButtonCell != nil))
|
||||
{
|
||||
shouldBeEnabled = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeEnabled = NO;
|
||||
}
|
||||
}
|
||||
else if ([validator
|
||||
respondsToSelector: @selector(validateMenuItem:)])
|
||||
{
|
||||
shouldBeEnabled = [validator validateMenuItem: item];
|
||||
}
|
||||
else if ([validator
|
||||
respondsToSelector: @selector(validateUserInterfaceItem:)])
|
||||
{
|
||||
shouldBeEnabled = [validator validateUserInterfaceItem: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeEnabled = YES;
|
||||
}
|
||||
|
||||
if (shouldBeEnabled != wasEnabled)
|
||||
{
|
||||
[item setEnabled: shouldBeEnabled];
|
||||
if (shouldBeEnabled != wasEnabled)
|
||||
{
|
||||
[item setEnabled: shouldBeEnabled];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Error Occurred While Updating Menu %@: %@", [self title], localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
// Reenable displaying of menus
|
||||
[self setMenuChangedMessagesEnabled: YES];
|
||||
}
|
||||
|
@ -1209,7 +1216,7 @@ static BOOL menuBarVisible = YES;
|
|||
NSEventType type = [theEvent type];
|
||||
unsigned modifiers = [theEvent modifierFlags];
|
||||
NSString *keyEquivalent = [theEvent charactersIgnoringModifiers];
|
||||
|
||||
|
||||
if (type != NSKeyDown && type != NSKeyUp)
|
||||
return NO;
|
||||
|
||||
|
|
Loading…
Reference in a new issue