Search code examples
macosnstableviewcocoa-bindingsnsarraycontrollerapplescript-objc

Deletion button for each table row in AppleScriptObjC


I'm trying to achive the button that is placed in every row of an table and deletes that row when pressed in AppleScriptObjC. Same as in Safari, when you look at the download list, there is small X button next to the name of a downloaded file.

I can't make the binding of deletion method deleteRow_(sender) in an app delegate with deletion button to work. I have Array Controller that fills the table. I have binded the button to the method but when clicked nothing happens. I have tried to bind the argument of each button to the unique value from the data source and set it's target to the app delegate itself but it makes the button transparent and unclickable.

Please help how can I make it work using AppleScriptObjC and bindings.


Solution

  • Thanks to @Willeke, I noticed that there was no delegate specified for the table. Table was bind to an property, property tableName : missing value in a delegate but not thru outlet delegate of an table.

    After specifying a delegate for the table, when I bind the action of an button to the same delegate as table view, everything works like a charm.

    Now, when action works the second part of this topic is how to obtain the row index or some other info about which button I have pressed? I tried to fill argument with a value taken from a dataSource. I have binded the button to the table cell view with objectValue.myValue as object key path and button cell bind to table controller with myValue of object key path. Target of both is bind to same delegate as table. but all this setup gives me an error. This binding is done in the same way I bind all my objects to fill the table.