Guilherme Sehn
Guilherme Sehn

Reputation: 6787

IBAction in table cell view won't be fired

I am making my first Mac OS X application and I'm stuck with a problem.

I created a NSTableView on my window linked to a NSArrayController and I'd like to call a method after stopping to edit a textfield cell. So I've selected to call an action when end editing, as you can see in the following screenshot:

enter image description here

After, I've created an IBAction for it:

It generated this code in my AppDelegate.h:

- (IBAction)stopEditingHeaderNameCell:(id)sender;

And then I edited the IBAction in AppDelegate.m in order to show a NSLog message when the cell is edited:

- (IBAction)stopEditingHeaderNameCell:(id)sender
{
    NSLog(@"test");
}

However, when I stop editing the cell by pressing enter or clicking in another element, nothing happens. I already tried to apply this IBAction to a NSTextField and it works perfectly, but it doesn't call the IBAction when applied to this text field cell.

Can anyone help me to solve this?

Thanks!

Upvotes: 1

Views: 489

Answers (1)

rdelmar
rdelmar

Reputation: 104082

This is not the way you do this with text field cells in a table view. You need to make your app delegate the delegate of the table (you can connect this in IB), and then implement controlTextDidEndEditing:. This method will be called when you end editing (by tabbing out of the cell or clicking on another row or column).

Upvotes: 1

Related Questions