But then I have to handle all the glyph changes somehow, like this:
from mojo.events import addObserver, removeObserver, postEvent
class DummyController(object):
def __init__(self):
self.glyph = CurrentGlyph()
addObserver(self, "currentGlyphChanged", "currentGlyphChanged")
self.addSelectionObserver()
def currentGlyphChanged(self, notification):
self.removeSelectionObserver()
self.glyph = notification["glyph"]
self.addSelectionObserver()
postEvent("selectionChanged")
def glyphSelectionChanged(self, notification):
postEvent("selectionChanged")
def addSelectionObserver(self):
if self.glyph is not None:
self.glyph.addObserver(self, "glyphSelectionChanged", "Glyph.SelectionChanged")
def removeSelectionObserver(self):
if self.glyph is not None:
self.glyph.removeObserver(self, "Glyph.SelectionChanged")
class DummyObserver():
def __init__(self):
addObserver(self, "selectionChanged", "selectionChanged")
def selectionChanged(self, notification):
self.glyph = notification["glyph"]
if self.glyph is not None:
print(self.glyph.selectedPoints, self.glyph.selectedComponents)
DummyController()
DummyObserver()
I was thinking there might be something like this already built in.