Reputation: 185
I have an NSTableView that displays a few rows and columns. The user is able to select multiple rows, and I'd like to be able to capture the cmd-c (copy) shortcut and do something custom (write the selected rows' info onto the clipboard).
So the question is how to set up a method so that it gets called when cmd-c is pressed in the context of the NSTableView being in focus right after selecting some rows with the mouse and keyboard?
Upvotes: 0
Views: 268
Reputation: 4660
The event is sent up the responder chain and caught in the copy:(id) method of for example an NSDOCUMENT if you have a NSDOCUMENT subclass. If your NSTABLEVIEW subclass acceptsFirstResponder a copy:(id) method should be enough.
Alternatively you can capture the key press in for example sendEvent:(NSEvent*)event
Upvotes: 1