Skip to content

Instantly share code, notes, and snippets.

@connordavenport
Created March 24, 2026 14:29
Show Gist options
  • Select an option

  • Save connordavenport/a8960ef07613165308ff7e35aa7b5d35 to your computer and use it in GitHub Desktop.

Select an option

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
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