mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Fix a few issues with toolbar item validation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27626 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d40bb8140a
commit
cdc21a5395
3 changed files with 39 additions and 20 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,6 @@
|
|||
2009-01-18 Wolfgang Lux <wlux@uni-muenster.de>
|
||||
|
||||
|
||||
2009-01-18 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSMenu.m (-update, -setAutoenablesItems:, initWithCoder):
|
||||
|
@ -7,6 +10,14 @@
|
|||
falling back to -validateUserInterfaceItem: if the validator
|
||||
doesn't respond to -validateMenuItem:.
|
||||
|
||||
* Source/NSToolbarItem.m (-validate): Fix broken implementation.
|
||||
* Source/NSToolbarItem.m (-validateMenuItem:) Add implementation
|
||||
to validate menu items in text only representation and in an
|
||||
overflow menu.
|
||||
* Source/GSToolbarView.m (-overflowMenu): Validate each toolbar
|
||||
item before adding a menu item to an overflow menu. Also rename
|
||||
method to make its purpose clear.
|
||||
|
||||
2009-01-17 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSDocument.m (-windowForSheet): Return nil if the
|
||||
|
|
|
@ -174,7 +174,7 @@ static void initSystemExtensionsColors(void)
|
|||
- (id) init;
|
||||
|
||||
// Accessors
|
||||
- (NSMenu *) returnMenu;
|
||||
- (NSMenu *) overflowMenu;
|
||||
/* This method cannot be called "menu" otherwise it would override NSResponder
|
||||
method with the same name. */
|
||||
|
||||
|
@ -235,13 +235,13 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
if ([event type] == NSLeftMouseDown)
|
||||
{
|
||||
return [self returnMenu];
|
||||
return [self overflowMenu];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSMenu *) returnMenu
|
||||
- (NSMenu *) overflowMenu
|
||||
{
|
||||
/* This method cannot be called "menu" otherwise it would
|
||||
override NSResponder method with the same name. */
|
||||
|
@ -264,7 +264,10 @@ static void initSystemExtensionsColors(void)
|
|||
menuItem = [item _defaultMenuFormRepresentation];
|
||||
|
||||
if (menuItem != nil)
|
||||
[menu addItem: menuItem];
|
||||
{
|
||||
[item validate];
|
||||
[menu addItem: menuItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1348,28 +1348,27 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
- (void) validate
|
||||
{
|
||||
/* Validate by default, we know that all of the
|
||||
"standard" items are correct. */
|
||||
NSMenuItem *menuItem = [self menuFormRepresentation];
|
||||
id target = [self target];
|
||||
BOOL enabled = YES;
|
||||
id target;
|
||||
|
||||
// No validation for custom views
|
||||
/* No validation for custom views */
|
||||
if (_view)
|
||||
return;
|
||||
|
||||
if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly
|
||||
&& menuItem != nil)
|
||||
target = [NSApp targetForAction: [self action] to: [self target] from: self];
|
||||
if (target == nil || ![target respondsToSelector: [self action]])
|
||||
{
|
||||
if ([target respondsToSelector: @selector(validateMenuItem:)])
|
||||
[self setEnabled: [target validateMenuItem: menuItem]];
|
||||
enabled = NO;
|
||||
}
|
||||
else
|
||||
else if ([target respondsToSelector: @selector(validateToolbarItem:)])
|
||||
{
|
||||
if ([target respondsToSelector: @selector(validateToolbarItem:)])
|
||||
[self setEnabled: [target validateToolbarItem: self]];
|
||||
}
|
||||
|
||||
// We can get a crash here when the target is pointing garbage memory...
|
||||
enabled = [target validateToolbarItem: self];
|
||||
}
|
||||
else if ([target respondsToSelector: @selector(validateUserInterfaceItem:)])
|
||||
{
|
||||
enabled = [target validateUserInterfaceItem: self];
|
||||
}
|
||||
[self setEnabled: enabled];
|
||||
}
|
||||
|
||||
- (NSView *) view
|
||||
|
@ -1388,7 +1387,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
// This method invokes using the toolbar item as the sender.
|
||||
// When invoking from the menu, it shouldn't send the menuitem as the
|
||||
// sender since some applications check this and try to get additional
|
||||
// information about the toolbar item which this is coming from.
|
||||
// information about the toolbar item which this is coming from. Since
|
||||
// we implement the menu's action, we must also validate it.
|
||||
//
|
||||
- (void) _sendAction: (id)sender
|
||||
{
|
||||
|
@ -1397,6 +1397,11 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
from: self];
|
||||
}
|
||||
|
||||
- (BOOL) validateMenuItem: (NSMenuItem *)menuItem
|
||||
{
|
||||
return [self isEnabled];
|
||||
}
|
||||
|
||||
- (NSMenuItem *) _defaultMenuFormRepresentation
|
||||
{
|
||||
NSMenuItem *menuItem;
|
||||
|
|
Loading…
Reference in a new issue