• 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: Built Menu not firing the action
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Built Menu not firing the action


  • Subject: Re: Built Menu not firing the action
  • From: Steve Cronin <email@hidden>
  • Date: Mon, 25 Aug 2008 14:12:14 -0500

Peter;

Thanks for the tip on NSStringFromSelector()!

On the responder chain: I'm not sure I precisely understand your question - where are you expecting me to call this?
If I call it at the time the submenu is being constructed I get: appDelegate
Since I can't get any response to selecting the item itself, I can't tell you what I would get if I called it when the item is invoked =;-(


If you use the NSMenu method -addItemWithTitle:(NSString *) action: (SEL) keyEquivalent:(NSString *)
what is the recommended way to set the target for the menuItem added by this method?
Why doesn't the method allow you to set the target as well as the selector, in one fell swoop?


How can I effect the responder chain, if I am just adding a submenu to menuitem on the menubar?

The REAL maddening thing here is that I have another similar data driven submenu that uses the same mechanism and it works fine.
I've been over and over the IB settings for the darn things and I can't find any differences!
Same point in time the submenu are being constructed and attached; and same exact objects involved in the selector....


Thanks for any additional data.
Steve



On Aug 25, 2008, at 1:20 PM, Peter Ammon wrote:


On Aug 25, 2008, at 12:53 AM, Steve Cronin wrote:

Folks;

I'm building a data driven submenu programmatically.
The submenu appears correctly in the UI with the correct titles but nothing happens when these items are selected.


[...]

I set a breakpoint at customAction:  it NEVER gets called.
(Yes I have spelled it correctly [- (void) customAction:(id)sender;]

This is on the mainMenu in the main XIB file. There is an outlet from appDelegate for mainMenu, this is set.
The menu itself has the appDelegate set as its' delegate.
The selector method is o method in the appDelegate object.
There are no selector bindings set.
(Note: there are enabled bindings set which are working correctly)

The most likely problem is that the object implementing the method is not in the responder chain. What object do you get if you call [NSApp targetForAction:@selector(customAction:)]?




I'm just stumped! I probably could use some sleep...
Also how do you show some useful data from a SEL value in NSLog? ie print [NSMenuItem action]?

For debugging purposes, the easiest thing to do is to cast it to a char*, e.g.:


gdb)  p (char *)[someMenuItem action]

For your actual code, you should use the NSStringFromSelector() function, as the char* nature of selectors is not guaranteed.

-Peter


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Built Menu not firing the action
      • From: Peter Ammon <email@hidden>
References: 
 >Built Menu not firing the action (From: Steve Cronin <email@hidden>)
 >Re: Built Menu not firing the action (From: Peter Ammon <email@hidden>)

  • Prev by Date: Re: monitoring file system
  • Next by Date: Re: Semi-transparent, blurred NSWindow background?
  • Previous by thread: Re: Built Menu not firing the action
  • Next by thread: Re: Built Menu not firing the action
  • Index(es):
    • Date
    • Thread