mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 04:21:00 +00:00
Fixed small NSMenu bugglets.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4574 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6b97b2f5e0
commit
ed724a3ae7
2 changed files with 35 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
1999-07-12 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
|
* Source/NSMenu.m: added code to convert anything that conforms to
|
||||||
|
<NSMenuItem> into an NSMenuItemCell. Not tested, but should work.
|
||||||
|
Also fixed a small bug in -init, it was not returning.
|
||||||
|
|
||||||
Mon Jul 12 5:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Mon Jul 12 5:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSOpenPanel.m: In ([-runModalForTypes:]) made change
|
* Source/NSOpenPanel.m: In ([-runModalForTypes:]) made change
|
||||||
|
|
|
@ -61,7 +61,7 @@ static NSZone *menuZone = NULL;
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
[self initWithTitle:@"Menu"];
|
return [self initWithTitle:@"Menu"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithTitle:(NSString *)aTitle
|
- (id)initWithTitle:(NSString *)aTitle
|
||||||
|
@ -89,13 +89,37 @@ static NSZone *menuZone = NULL;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* - (void)insertItem:(id <NSMenuItem>)newItem
|
||||||
|
* atIndex:(int)index
|
||||||
|
*
|
||||||
|
* This method has been modified to convert anything that conforms to the
|
||||||
|
* <NSMenuItem> Protocol into a NSMenuItemCell which will be added to the
|
||||||
|
* items array.
|
||||||
|
*
|
||||||
|
* Blame: Michael
|
||||||
|
*/
|
||||||
|
|
||||||
- (void)insertItem:(id <NSMenuItem>)newItem
|
- (void)insertItem:(id <NSMenuItem>)newItem
|
||||||
atIndex:(int)index
|
atIndex:(int)index
|
||||||
{
|
{
|
||||||
if ([(NSMenuItemCell *)newItem isKindOfClass:[NSMenuItemCell class]])
|
if ([newItem conformsToProtocol:@protocol(NSMenuItem)])
|
||||||
|
{
|
||||||
|
if ([newItem isKindOfClass:[NSMenuItemCell class]])
|
||||||
[menu_items insertObject:newItem atIndex:index];
|
[menu_items insertObject:newItem atIndex:index];
|
||||||
else
|
else
|
||||||
NSLog(@"You must use an NSMenuItemCell, or a derivative thereof.\n");
|
{
|
||||||
|
[self insertItemWithTitle:[newItem title]
|
||||||
|
action:[newItem action]
|
||||||
|
keyEquivalent:[newItem keyEquivalent]
|
||||||
|
atIndex:index];
|
||||||
|
[(NSMenuItem *)newItem release];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
NSLog(@"You must use an object that conforms to NSMenuItem.\n");
|
||||||
|
|
||||||
|
menu_changed = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <NSMenuItem>)insertItemWithTitle:(NSString *)aString
|
- (id <NSMenuItem>)insertItemWithTitle:(NSString *)aString
|
||||||
|
@ -117,13 +141,7 @@ static NSZone *menuZone = NULL;
|
||||||
|
|
||||||
- (void)addItem:(id <NSMenuItem>)newItem
|
- (void)addItem:(id <NSMenuItem>)newItem
|
||||||
{
|
{
|
||||||
// The spec says we call [self insertItem]; but why waste the overhead?
|
[self insertItem:newItem atIndex:[menu_items count]];
|
||||||
if ([(NSMenuItemCell *)newItem isKindOfClass:[NSMenuItemCell class]])
|
|
||||||
[menu_items insertObject:newItem atIndex:[menu_items count]];
|
|
||||||
else
|
|
||||||
NSLog(@"You must use an NSMenuItemCell, or a derivative thereof.\n");
|
|
||||||
|
|
||||||
menu_changed = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString
|
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue