UNSOLVED Command Palette
tallpauley last edited by gferreira
I was thinking it'd be fun to make a "command-palette" extension like in Sublime Text, Atom and VSCode. For those of you who aren't using these editors, it can enable you to do a lot via the keyboard without remembering keyboard shortcuts (in fact it can even show you the keyboard shortcut for future reference).
Through the API, how can I access all the actions available to map to hot keys (glyph view and space center) and short keys? I tried getMenuShortCuts which returned an empty Dictionary. Then I looked at programmatically iterating through the menu bar to get all those "actions", but that feels hacky. Any tips where to look?
I'm guessing it'd be whatever API RoboFont uses itself to populate "Short Keys" and "Hot Keys" lists in Preferences. In fact, the interface for "Short Keys" already has the autocomplete I'd need as well.
gferreira last edited by gferreira
the default shortcuts are indeed not returned by
getMenuShortCuts, and are currently not accessible from the public API. (maybe this could be added?)
it’s possible to get them using the internal
libmodule (see example below). you can use stuff from the lib in your scripts, but ⚠️ the API may change over time, without a nice deprecation warning like
from lib.tools.shortCutTools import getShortCuts from lib.UI.fileBrowser import shortKeyToString shortcuts = getShortCuts() for key, item in shortcuts.items(): if item.keyEquivalent(): shortkey = item.keyEquivalentModifierMask(), item.keyEquivalent() print(key, item, shortkey)
see also a sketch for a simple search UI here (please fork and change as you wish)
I haven’t been able to figure out how to run the commands… @frederik help :)
this could become a very useful extension!
edit: updated the gist, now it also runs the command (thanks @frederik)
tallpauley last edited by
Thanks @gferreira, this is very helpful! I'll play around with the code you gave me
tallpauley last edited by
@tallpauley Thanks for the update to run the command! This gives me something to play around with.
To take it a step further, is there a lib API I can use to also pull in space center and glyph view shortcuts, like whatever they use to populate their "Hot Keys" tabs? (Btw, I won't filter out commands that don't have shortcut keys, this is part of the allure of having a command palette, you can access commands that don't have shortcuts keys defined yet).
I saw mojo.UI.setGlyphViewDisplaySettings, but this isn't all the available commands for glyph view. For space center I didn't see any API in mojo.UI
I would dig around myself, but I think you guys compile to
.pycand I don't want to violate the EULA by reverse engineering (hence me actually clicking on the EULA lol). Once I have all the commands available, I think I should have what I need.