开发者

Get currently selected item in Mac UI

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜