SOLVED font selection changed callback
-
Hi,
Is there any event posted when selected glyphs in a font window change and how can I add it as an observer?
Thanks,
Bahman
-
ps.
currentGlyphChanged
notifications are also sent when the current glyph changes in the glyph window. so you’ll probably first want to check if the current window is the font window:from mojo.events import addObserver from mojo.UI import CurrentWindow class MyObserver: def __init__(self): addObserver(self, 'currentGlyphChangedCallback', "currentGlyphChanged") def currentGlyphChangedCallback(self, notification): if CurrentWindow().doodleWindowName == 'FontWindow': print(CurrentFont().selectedGlyphNames) MyObserver()
-
hi @bahman,
glyph selection changes in the Font Overview send out
currentGlyphChanged
andglyphCollectionDraw
notifications.you can use the EventObserver extension to see which notifications are being sent as you click around in the app:
here’s a simple font selection observer example (based on this one):
from mojo.events import addObserver class MyObserver: def __init__(self): addObserver(self, 'currentGlyphChangedCallback', "currentGlyphChanged") def currentGlyphChangedCallback(self, notification): print(CurrentFont().selectedGlyphNames) # and/or templateSelectedGlyphNames MyObserver()
this will keep observing until you close the application. you can also attach the observer to a window, and remove the observer when the window closes – see the List font layers example.
hope this helps. good luck!