Created
March 24, 2026 14:29
-
-
Save connordavenport/a8960ef07613165308ff7e35aa7b5d35 to your computer and use it in GitHub Desktop.
when opening a new glyph window, with shift down, force glyph to use current glyph window, regardless of the font
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, unregisterRoboFontSubscriber | |
| from mojo.UI import CurrentGlyphWindow | |
| import AppKit | |
| class force_same_window(Subscriber): | |
| debug = True | |
| def build(self): | |
| self.windowToClose = None | |
| self.windowTofocus = None | |
| def glyphEditorWillOpen(self, info): | |
| current_editor = CurrentGlyphWindow() | |
| editor = info.get("glyphEditor") | |
| glyph = info.get("glyph") | |
| if self.shift and (editor is not None) and (glyph is not None): | |
| if editor != current_editor: | |
| current_editor.setGlyph(glyph) | |
| self.windowToClose = editor | |
| self.windowTofocus = current_editor | |
| def glyphEditorDidOpen(self, info): | |
| if info["glyphEditor"] == self.windowToClose: | |
| self.windowToClose.close() | |
| if self.windowTofocus: | |
| self.windowTofocus.w.getNSWindow().makeKeyAndOrderFront_(None) | |
| @property | |
| def shift(self) -> bool: | |
| return AppKit.NSEvent.modifierFlags() & AppKit.NSShiftKeyMask | |
| if __name__ == '__main__': | |
| registerRoboFontSubscriber(force_same_window) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment