Adding a delete button to a CPTableView column in Cappuccino

266 Views Asked by At

This seems like it would be an easy thing to do but I am having a lot of trouble getting a button to respond to events while in a CPTableView. Here is the initialization code:

//deleteColumn is hooked up to CIB table column.

[deleteColumn setEditable:YES];
[deleteColumn setWidth:24];
var deleteButton = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
[deleteButton setTarget:self];
[deleteButton setAction:@selector(deleteClicked:)];
[deleteColumn setDataView:deleteButton];

I then have this selector code in the same view controller:

- (void)deleteClicked:(id)sender
{
    console.log(sender);
}

It seems the table view is squashing any mouse clicks inside it because I don't get the console log when I click the button.

Is there an easy way to do this? All I want is a button that deletes corresponding row in the table.

1

There are 1 best solutions below

1
Alexander Ljungberg On BEST ANSWER

The CPTableView takes over the action of the button for its own purposes. Try listening for the regular edit delegate message CPTableViewDataSource:tableView:setObjectValue:forTableColumn:row: in your table delegate.