Re: NSMenuItem: [ ] Bug [ ] Unexpected Behavior [ ] Answer forthcoming
Re: NSMenuItem: [ ] Bug [ ] Unexpected Behavior [ ] Answer forthcoming
- Subject: Re: NSMenuItem: [ ] Bug [ ] Unexpected Behavior [ ] Answer forthcoming
- From: Andrew Platzer <email@hidden>
- Date: Fri, 25 May 2001 11:18:49 -0700
On Friday, May 25, 2001, at 08:30 , Stiphane Sudre wrote:
>
From what I've seen, a NSMenuItem in a NSMenu in a the menu bar when it
>
is created in IB is disabled as long as there is no Action/Target
>
linked to it.
>
As soon as you create this link, the NSMenuItem is enabled.
>
Then could someone explain me why when you do a [thisAnnoyingMenuItem
>
setEnabled:NO]; it stays enabled ?
By default, the menu has autoenableItems set to YES. This means that
before tracking in the menu begins, it enables all items that have
target/action and then for each item, it calls
validateUserInterfaceItem: on the target and then up the responder
chain. If none of the objects in the chain this implements this method,
it assumes the item should always be enabled. If you want to disable the
item, implement this method and have it return NO.
Usually, it's something like:
- (BOOL)validateUserInterfaceItem:(id)anItem {
SEL action = [anItem action];
if (action==@selector(myAction:)) {
return [self myActionEnabled];
}
return NO; // disabled
}
Andrew
__________________________________________________________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e