How to trigger an action from a NSTableCellView in view based NSTableView when using bindings

Posted by user1075752 on Stack Overflow See other posts from Stack Overflow or by user1075752
Published on 2012-09-04T15:27:31Z Indexed on 2012/09/05 3:38 UTC
Read the original article Hit count: 1286

I'm facing a problem with a view-based NSTableView running on 10.8 (target is 10.7, but I think this is not relevant).

I'm using an NSTableView, and I get content values for my custom NSTableCellView through bindings. I use the obejctValue of the NSTableCellView to get my data.

I added a button to my cell, and I'd like it to trigger some action when clicked. So far I have only been able to trigger an action within the custom NSTableCellView's subclass.

I can get the row that was clicked like this, using the chain:

NSButton *myButton = (NSButton*)sender;    

NSTableView *myView = (NSTableView*)myButton.superview.superview.superview;

NSInteger rowClicked = [myView rowForView:myButton.superview];

From there I don't know how to reach my App Delegate or controller where the action is defined.

As I am using cocoa bindings, I do not have a delegate on the NSTableView that I could use to trigger my action.

Do you have any idea how I could talked back to controller ?

Many thanks in advance!

© Stack Overflow or respective owner

Related posts about nstableview

Related posts about cocoa-bindings