Contextual Menu in font view?

RoboFont Forums Help / General Contextual Menu in font view?

This topic contains 2 replies, has 2 voices, and was last updated by  Jens K. 4 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6247

    Jens K.
    Participant

    I saw this in the RF 1.7 release notes:

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

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

    Thanks,
    Jens

    #6251

    frederik
    Keymaster

    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()
    
    #6259

    Jens K.
    Participant

    Nice, thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.