Re: Bindings&Actions on Document-based Applications
Re: Bindings&Actions on Document-based Applications
- Subject: Re: Bindings&Actions on Document-based Applications
- From: Michael Clark <email@hidden>
- Date: Sun, 18 Sep 2005 20:07:06 -0400
Hi.
I am pretty sure I get what you are asking, but, maybe not. But here
goes.
I don't think you can do this without writing a single line of code.
You can do it with very little code. Here is what I would do.
In your main WindowController, the one that controls the nib with the
ArrayController in it you need to write a very basic method like this:
- (IBAction)invokeAddOnArrayController: (id)sender;
{
[myArrayController insert:sender];
}
Then load up the main nib, MainMenu.nib, in InterfaceBuilder. You
want to now add this method to the FirstResponder. You that by
selecting FirstResponder in the suit case, then selecting the Classes
tab, then shift-clicking on FirstResponder. Then in the inspector
you will be able to add an action. Click the Add button and enter
in: invokeAddOnArrayController:
Now you can go back to the Instances tab, and make a connection from
your menu item to the FirstResponder in the suitcase. Control-drag
from the menu item to the FirstResponder and select the new action
you just added.
Now when you select that menu item your action should be invoked
adding a new object to your array controller.
Hope that helps, and makes sense!
Michael.
On 18-Sep-05, at 9:49 AM, Kris Gybels wrote:
Hi all,
I have made a basic document-based application with each document
showing a table which is linked using cocoa bindings to an
NSArrayController. Now, I want the "Add new element to table" menu
item to invoke the "add:" action of NSArrayController, on the
controller for the currently active document. I have some trouble
figuring out how to do this since the main menu and the document
window/controllers are specified in two separate nibs. So can
anyone explain to me or point me to the right documentation on how
you do this in IB without writing a single line of code?
It seems like a very, very basic question, so I would be surprised
if itsn't explained somewhere already, but so far, all of the
examples I've seen of Cocoa bindings were not document-based. And
the one example I saw (unfortunately don't remember which) didn't
do it without implementing extra code (by linking the menu item to
a main application controller, which then forwarded the message to
the currently active document).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40marketcircle.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden