I want to get the currently selected item (text, image, etc) and display in my Cocoa app's window when a keyboard shortcut is hit. Drop开发者_开发技巧lr has functionality like this, for example. How do I go about doing this?
For example, I want it to return "(text, image, etc)" as text when that text selected on the screen like this: http://drp.ly/JAdv
The easiest way is to write a service and assign a keyboard shortcut to it. Services are designed to do exactly this: operate on the selected text, graphics, etc. (or insert information at the selection).
NSResponder * activeControl = [currentWindow firstResponder];
精彩评论