4

I set NSButtonCell as a cell type in a Table Column in my NSTableView. I implemented an IBAction method, but I can't wire it with NSButtonCell in IB - the wire don't want to highlight a button from NSTableView.

How to connect a method with NSButtonCell? Or maybe there'se another way to handle its click event?

Thanks

Ilya Blokh
  • 11,923
  • 11
  • 52
  • 84

1 Answers1

7

You should be able to wire up a connection from the cell by control+dragging to any object in your NIB. Just make sure the cell is actually selected, and that your action is defined as an IBAction in the object's header file. In your action method you can determine which row was selected by calling [tableView clickedRow].

Edit: Here's a demonstration. Make sure you click at least four times on the check box to get it selected, hold down the control key and drag from the cell to your object.

enter image description here

Francis McGrew
  • 7,264
  • 1
  • 33
  • 30
  • I need to wire a `NSButtonCell` with `IBAction` method. If I select `NSButtonCell` and then make right-click on my CustomClass object to see `Received Actions` list, the selection of `NSButtonCell` disappears. If I try to wire from NSButtonCell's `Received Actions` list - where I can find `IBAction` method to bring a wire to it? – Ilya Blokh Dec 15 '11 at 19:45
  • I've added an image to make it clear. You need to control drag *from* the cell onto the receiving object. – Francis McGrew Dec 15 '11 at 20:25
  • All rigth now!Previously I tryed to bring a wire from cell's `performClick` event in `Received Action` list, not from the cell object itself. Thanks for showing a patience in answering stupid question :) – Ilya Blokh Dec 16 '11 at 05:45
  • 3
    Thanks for the part about clicking at least four times! On a side note, in case anyone else was also confused, the reason you can call `[tableView clickedRow]` is because the `NSTableView` is the sender of the action, **not** the `NSButton`. – pepsi Feb 21 '12 at 17:25
  • Quick note: you can shift-control- (or right-) click on a control to get a list of all the controls at that point (z-order: top-down) and then select the control you want from that list. – geowar May 07 '14 at 00:36