문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top