Search code examples
cocoadelegatestableviewnstableview

Deleting entries from tableview with keypress


I have a simple cocoa application with a table view displaying a few entries. I want the user to be able to delete any entry he wants by simply selecting it in the table and pressing "Delete". How do I detect the keypress of "Delete" and how do I know if it occurs when the user has selected an entry in the tableview?

**Edit: in case I've not made it clear, "Delete" refers to the backspace key on a mac keyboard and not a GUI button.


Solution

  • Another option is to just assign a key equivalent (keyboard shortcut) to the Edit menu's "Delete" item and set its action to your controller's delete: method.