SOLVED BaseEventTool setup vs. becomeActive
bahman last edited by gferreira
What is the real purpose for the method
BaseEventTool? 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 to
becomeActivemethod? 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())
gferreira last edited by gferreira
the Simple example tool shows both
according to the docs,
setup()should be used to set the necessary attributes for the tool.
hope this makes sense… cheers
setupis 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.
setupis also called when you jump back from on other window or an other app.
bahman last edited by
Thank you, this makes it more clear.