I mean a "Cocoa bindings" kind of binding. e.g. the "target" binding of the menu item is bound in IB. The action field of the binding is set to "print:". I'm not talking about the traditional way of connecting a button/menu item to another object through the basic control drag from source to target and select the action method and I'm not talking about setting it in code. I know how to do both of those and they work, what I'm going for is a dynamic target.

->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



On Apr 1, 2009, at 7:12 AM, Andy Lee wrote:

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:
I have a menu item that is bound to a target. The menu is resides in has "Auto Enables Items" checked which means that it should call -validateMenuItem on a items target if it is available. However validate is never called on the target. If I remove the binding and set the target to one of the objects manually in IB the validation method is called as expected. Has anyone else run into this and if so, is there a work around?

What do you mean "binding"? "Binding" has a very specific meaning, and is not how you connect an object to its target.

Do you mean you're making the connection in code? If so, it should look something like:

   [myMenuItem setTarget:myTarget];
   [myMenuItem setAction:@selector(doMyAction:)];

Note the name of the action method is "doMyAction:", not "doMyAction", though I don't know if this affects whether validateMenuItem: is called.

Assuming your code does look like this, are you sure these lines of code are being executed? If so, *when* are they being executed? If you doing this in init, it's possible myMenuItem and myTarget have not been set yet -- you need to make the connection in awakeFromNib.

--Andy


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to