SOLVED Contextual Menu in font view?



  • I saw this in the RF 1.7 release notes:

    Add contextual menu event in font overview with this notification: fontOverviewAdditionContextualMenuItems

    Could you give an example of how it’s used?

    Thanks,
    Jens



  • Nice, thank you!


  • admin

    this should work in RoboFont 1.7

    good luck

    from mojo.events import addObserver
    
    class test(object):
        
        def __init__(self):
            
            addObserver(self, "fontOverviewAdditionContextualMenuItems", "fontOverviewAdditionContextualMenuItems")
            
        def fontOverviewAdditionContextualMenuItems(self, notification):
            myMenuItems = [
                ("Hello", self.sayHello), 
                ("World", self.sayWorld),
                ("submenu", [("an item", self.sayAnItem)])
                ]
            notification["additionContextualMenuItems"].extend(myMenuItems)
        
        def sayHello(self, sender):
            print "Hello"
        
        def sayWorld(self, sender):
            print "World"
        
        def sayAnItem(self, sender):
            print "an item"
    
    test()