简体   繁体   中英

Keyboard shortcut view for OS X application?

I've seen this kind of UI in several different apps:

图片

I'm not sure if there's an open source project that does something similar (I've searched all over github but haven't found anything), but I'd like to verify my approach on implementation before getting started (since I'm a cocoa noob).

I can subclass nstextview, and have the special character grey background as a background. Then, on keydown, update that background image to be the appropriate image. Then, I'll need to do some kind of big switch statement/reverse lookup of the keycode to the string representation of what was pressed and use that.

Does that make sense?

There are several open source implementations of this kind of control. Two notable ones are ShortcutRecorder and MASShortcut . Neither of them look exactly like this particular example but it shouldn't be difficult to customize them visually. The hard stuff (translating key codes, registering shortcut handlers, etc.) is done for you by these libraries, so they would be a good starting point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM