• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Enable a NSMenuItem created programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enable a NSMenuItem created programmatically


  • Subject: Re: Enable a NSMenuItem created programmatically
  • From: Dan Bernstein <cocoa-dev%email@hidden>
  • Date: Sun, 30 Mar 2003 18:17:25 +0300

The action method should take a single id argument (commonly called sender):

- (void)myAction:(id)sender

and thus should be specified as @selector(myAction:)

(note the colon!)

Moreover, since you don't specify a target for the menu item, it will be enabled only if and when the object implementing myAction: is in the responder chain.

HTH
-- Dan

On Sunday, March 30, 2003, at 06:01 PM, Arthur VIGAN wrote:

Hi,

my application creates a menu programmatically to handles changes in the applications state, and I have a problem with the items created. I use the following to make the items:

myMenuItem = [[NSMenuItem alloc] initWithTitle:@"The title" action:@selector(myAction) keyEquivalent:@""];
[myMenu insertItem:myMenuItem atIndex:0];

the method myAction is in the same class that create the menu items and the menu.
The problem is that the item stays disabled when the application runs... even if I use [myMenuItem setEnabled:YES];

Where is the problem?

Thanks a lot in advance.

-- Arthur
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Enable a NSMenuItem created programmatically (From: Arthur VIGAN <email@hidden>)

  • Prev by Date: Re: Enable a NSMenuItem created programmatically
  • Next by Date: Re: How to detect whether a filename points to a text clipping?
  • Previous by thread: Re: Enable a NSMenuItem created programmatically
  • Next by thread: HIView elements in Cocoa window?
  • Index(es):
    • Date
    • Thread