SOLVED Contextual Menu in Glyph View
-
Is there any way to build my own contextual menu in the Glyph View?
I'm looking for similar solution as the one given in the example:
linkThanks in advance for your help.
-
A tool can have his own contextual menu item:
from mojo.events import EditingTool, installTool class MyTool(EditingTool): def additionContextualMenuItems(self): return [ ("Hello", self.sayHello), ("World", self.sayWorld), ("submenu", [("an item", self.sayAnItem)]) ] def sayHello(self, sender): print("Hello") def sayWorld(self, sender): print("World") def sayAnItem(self, sender): print("an item") installTool(MyTool())
It not possible to directly inject menu item into the each menu for each tool. I will think about this and take it with me of the upcoming release.
-
mmm, RF could use the changes I’ve committed to vanilla.
see https://github.com/typesupply/vanilla/blob/master/Lib/vanilla/vanillaList.py#L196
for vanilla you can also provide the state, image and if the menu item is enabled.
-
Hey @frederik, Is it possible to add
additional-contextual-menu-item
that will look/work like a checkbox to theBaseEventTool
? (like the "lock image" checkbox in the example-screenshot that you shared?)(I know I can easily go around it and do it without a check sign. But I consider the check sign more practical)
-
Thanks for the response. I will wait for new solutions then :)
-
A tool can have his own contextual menu item:
from mojo.events import EditingTool, installTool class MyTool(EditingTool): def additionContextualMenuItems(self): return [ ("Hello", self.sayHello), ("World", self.sayWorld), ("submenu", [("an item", self.sayAnItem)]) ] def sayHello(self, sender): print("Hello") def sayWorld(self, sender): print("World") def sayAnItem(self, sender): print("an item") installTool(MyTool())
It not possible to directly inject menu item into the each menu for each tool. I will think about this and take it with me of the upcoming release.