Re: Calling IB Actions In PB
Re: Calling IB Actions In PB
- Subject: Re: Calling IB Actions In PB
- From: j o a r <email@hidden>
- Date: Sun, 14 Apr 2002 16:01:21 +0200
- Resent-date: Sun, 14 Apr 2002 16:28:18 +0200
- Resent-from: j o a r <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
On Sunday, April 14, 2002, at 03:44 , Albert Atkinson wrote:
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(openDocument:)];
<snip>
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(newDocument:)];
You should ask yourself, "what object is responding to these action
methods". In this case it looks to be a document controller, perhaps
even the shared / default dito? If so, try something like this:
[toolbarItem setTarget:[NSDocumentController sharedDocumentController]];
The reason that you didn't know this is because normally these actions
are sent from a menu item, and the glue to the object is handeled by a
piece of Cocoa magic know as "first responder". This is not something
that is easy to grok at first - but it's not a very difficult concept,
and definitively one of the things that make Cocoa great, so you should
learn it sooner rather then later... :)
Read the documentation for NSResponder and the "first responder chain",
and the overview / topic documentation for event handling - that is
linked from the documentation of NSResponder.
Good luck,
j o a r
_______________________________________________
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.