SOLVED BaseEventTool setup vs. becomeActive
-
Hi,
What is the real purpose for the method
setup
inBaseEventTool
? I just realized it gets executed on glyph switch. It seems to me the description of this method is not clear. When it gets executed and how it should be used as opposed tobecomeActive
method? Please check this following example:from mojo.events import BaseEventTool from vanilla import FloatingWindow from defconAppKit.windows.baseWindow import BaseWindowController from mojo.events import installTool, uninstallTool, getToolOrder class MyTool(BaseEventTool): def setup(self): print('setup') def becomeActive(self): print("tool became active") def becomeInactive(self): print("tool became inactive") class ToolActivator(BaseWindowController): def __init__(self, tool): self.w = FloatingWindow((123, 44), 'Test tool') self.tool = tool # install the tool installTool(self.tool) # initialize the window self.setUpBaseWindowBehavior() self.w.open() def windowCloseCallback(self, sender): # if the tool is active, remove it tools = getToolOrder() if self.tool.__class__.__name__ in tools: uninstallTool(self.tool) super(ToolActivator, self).windowCloseCallback(sender) ToolActivator(MyTool())
Thanks,
Bahman
-
Thank you, this makes it more clear.
-
setup
is called when a glyph is switched inside the glyph view (fe by the jump to glyph popup window) cause maybe you need to setup your tool differently with the new glyph data.setup
is also called when you jump back from on other window or an other app.
-
hello @bahman,
the Simple example tool shows both
setup
andbecomeActive
in action.according to the docs,
setup()
should be used to set the necessary attributes for the tool.hope this makes sense… cheers