Re: Binding Target of NSButtonCells inside of an NSTableView
Re: Binding Target of NSButtonCells inside of an NSTableView
- Subject: Re: Binding Target of NSButtonCells inside of an NSTableView
- From: Clark Cox <email@hidden>
- Date: Fri, 17 Jun 2005 09:24:45 -0400
On 6/16/05, Tim Lucas <email@hidden> wrote:
> On 17/06/2005, at 6:14 AM, Clark Cox wrote:
> > I have an NSTableView that is populated via bindings. So far, so good,
> > the correct data is displayed, etc. However, one of the columns has
> > NSButtonCell as its dataCell. I simply want a click in one of these
> > buttons to call a method on the model object backing it's row.
> >
> > Currently, in IB, I have the binding on the table column set like so:
> >
> > "target" is bound to <the NSArrayController>.selection, with a
> > selector of "selectFilename:"
> > "argument" is also bound to <the NSArrayController>.selection.
> >
> > However, clicking any of the buttons in this column does nothing. My
> > method isn't called, I get no console messages, etc. Setting up a
> > NSButton outside of the table, with the same bindings gets my method
> > called. Is there some trick to that makes binding button cells in a
> > table view somehow different than binding freestanding buttons?
>
> You should be binding to arrangedObjects rather than selection, just
> like you do a textfield.
>
> If there's no argument to the method, you just have to set up the
> binding as follows:
> Target:
> Bind to: MyArrayController
> Controller Key: arrangedObjects
> Selector Name: myMethod
>
> Remember also to bind to the table column, not the the button cell.
I've put together a small project that illustrates my problem:
http://homepage.mac.com/clarkcox3/files/Test.zip
In the nib of this project, there is a table view, two columns of
which are simple text cells. The third contains button cells, as in my
real app, that are bound in the same fashion. Again, clicking the
buttons does nothing -- my method isn't called, I get no warning/error
about a missing method, or about anything to do with my bindings.
I'm sure that whatever I'm missing is incredibly simple, but I can't
seem to see it. I'd appreciate it if someone more knowledgeable than I
could point it out to me.
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
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