Last active
March 8, 2025 14:57
-
-
Save okay-type/5ff7c9a24162884680b06461a1352abb to your computer and use it in GitHub Desktop.
return to the previous CurrentGlyph rf4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mojo.subscriber import Subscriber, registerRoboFontSubscriber | |
| from mojo.UI import SetCurrentGlyphByName | |
| ''' | |
| keep track of the most recent currentGlyph and return to it using ⇧+, | |
| recent update: | |
| no longer tied to the edit glyph window - you can now close a glyph, open a new glyph, and then ⇧+, back to the previous glyph | |
| ''' | |
| class previousCurrentGlyph(Subscriber): | |
| debug = False | |
| def build(self): | |
| self.previousGlyph = [None, None] | |
| def glyphEditorDidSetGlyph(self, info): | |
| glyph = info['glyph'] | |
| if glyph is None: | |
| return | |
| if glyph.name != self.previousGlyph[1]: | |
| self.previousGlyph = [self.previousGlyph[1], glyph.name] | |
| def glyphEditorDidKeyDown(self, info): | |
| deviceState = info['iterations'][0]['deviceState'] | |
| keyDown = deviceState['keyDown'] | |
| shiftDown = deviceState['shiftDown'] | |
| if keyDown == '<' and shiftDown != 0 and self.previousGlyph[0] != None: | |
| SetCurrentGlyphByName(self.previousGlyph[0]) | |
| registerRoboFontSubscriber(previousCurrentGlyph) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment