I’d like to detect keypresses in the Edit View. I know we can detect modifier keys along with the space key with
What is the best way to detect key codes of other non-modifier keypress events (such as arrows, characters)?
Because this is part of a general plugin, the method of creating a script and assigning a shortcut through System Preferences wouldn’t work…
Any pointers would be helpful.
Normally you would have to add a
keyDown_(event) method, which passes an
NSEvent, from which you can deduce the key pressed by analyzing
But… I am not sure we support that in .glyphsPlugin extensions.
What are you trying to do?
Thanks for your help!
Where / how would I add the keyDown_(event) method?
The examples I’m finding so far add the keyDown method on a separate window/view, not on the Glyphs window controller.
I’m trying to execute some methods (which involve updating the current tab text, among others) triggered by keystrokes while in the Edit View.
You could add a menu item with a shortcut. But if you use single keystrokes (without modifier keys), you will not be able to type those keys when in the Text Tool.
I would need to add some code to allow this in a general way.
Unfortunately, because it’s dependent on other parts of the plugin, adding a standalone script in the menu is not possible. If you do end up implementing an api for this, it would be super helpful! Thanks anyways.
I don’t mean adding a script. You can add a menu item from code. The “General Plugin” has sample code for it.
I see — thanks for clarifying, I understand. It would be best if we can package these commands as part of the plugin, but I’ll try out this method of adding additional menu items. Thank you!