开发者

Get currently selected item in Mac UI

开发者 https://www.devze.com 2022-12-25 04:17 出处:网络
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

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

精彩评论

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