Re: NSTableView - Open Panel on Double Click
Re: NSTableView - Open Panel on Double Click
- Subject: Re: NSTableView - Open Panel on Double Click
- From: "Kyle Sluder" <email@hidden>
- Date: Thu, 21 Feb 2008 00:01:29 -0500
On Wed, Feb 20, 2008 at 11:46 PM, Grant Limberg <email@hidden> wrote:
> The panel I'd like to open is also part of MainMenu.nib called
> EditorPanel.
You almost always want to put things like this in their own nib. How
do you show multiple panels at once? Even if you don't want to, there
are plenty of practical reasons for putting this panel in its own nib,
not the least of which is that it makes working with
NSWindowController possible.
In fact, your main window should probably be in its own nib as well.
> Is there a way set the EditorPanel as the target of the
> Double Click Target on the Table View Bindings pane? Or is this
> something that can only be done with code?
The reason this is present on the bindings pane is so that you can
easily pass arguments to a controller. For example, say you bind the
columns of your table view to different keys of a collection of
objects retrieved through an NSArrayController. You need to have an
object that knows what to do when a row in your table is
double-clicked. For your purposes, this will most likely be an
application delegate instantiated in your nib, since your window
exists in MainMenu.nib. If you were to split your window off into its
own nib, you would probably want to use the first responder proxy as
your target since the application delegate forms part of the responder
chain.
So you implement -tableDoubleClicked in your application delegate.
How would this method know what to do without querying the table or
array controller for the current selection (both of which are not
precisely equivalent to "the row that was just double-clicked")? The
solution is to provide this method an argument, which is the purpose
of the doubleClickArgument binding(s). You would bind that to your
NSArrayController's arrangedObjects key, and redefine your method as
-tableDoubleClickedOnObject:, which takes an id (or NSObject, or
NSManagedObject...) as its argument. Now you can act upon this object
by creating an NSWindowController with the nib containing your panel.
Your panel can bind through the NSWindowController to the appropriate
model object.
--Kyle Sluder
_______________________________________________
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