Tagged: BaseEventTool
This topic contains 4 replies, has 2 voices, and was last updated by Anonymous 5 years, 5 months ago.
-
AuthorPosts
-
April 26, 2015 at 18:37 #6138
AnonymousHi,
In a class derived from BaseEventTool, I use
g = self.getGlyph()
f = g.getParent()
in order to obtain the font containing the glyph g.
However, when I have two opened fonts F1 and F2 and two GlyphWindows opened (one from each font : g1 from F1 and g2 from F2), and when I go from one glyph window to the other, the following code :
print g.name, g.getParent.fileName
gives me : g1 F2 or g2 F1
and after some more clicking, I finally get correct values (g1 F1 or g2 F2)There seem to be only partially updated information when switching windows.
Regards,
SamuelApril 27, 2015 at 13:25 #6139hi
could you make an small example?
I cannot reproduce this issue, with a quick test…
thanks
from mojo.events import BaseEventTool, installTool class TestTool(BaseEventTool): def currentGlyphChanged(self): g = self.getGlyph() f = g.getParent() print g.name, f installTool(TestTool())April 27, 2015 at 18:56 #6140
Anonymous[ With Version 1.6 (built 1410152315) ]
Using your example TestTool :
– Open two fonts F1 and F2
– Open glyph g1 from font F1
(now there are three windows opened, plus the output window)
– Bring the window for the font F2 to the front
– click on the glyphs grid, on a glyph g2 (with a name different from g1)
Now you should observe “g1 <F2>” in the output window[Another weirdness: the callbacks “viewDidChangeGlyph” and “currentGlyphChanged” are called before “becomeActive”]
Best regards,
SamuelMay 4, 2015 at 08:13 #6146Hi
the mixed parents will be fixed in the next update, thanks for reporting
one thing: a
tool.getGlyph()method will always return a glyph from a glyph view, if you select a font window, it will send you acurrentGlyphChangednotification, but the glyph will not actually change when using thetool.getGlyph(). To get the global current glyph useCurrentGlyph()the other weirdness: see https://github.com/typemytype/RoboFontExamples/blob/master/observers/eventObserver.py
a tool can become active separately from a
currentGlyphChangedorviewDidChangeGlyphMay 5, 2015 at 11:33 #6149
AnonymousThank you for fixing this.!
I’ll use your eventObserver example to get a better understanding of when each event is triggered.
Regards,
Samuel -
AuthorPosts
You must be logged in to reply to this topic.