UNSOLVED Contextual menu — enable/disable entries?



  • Hiii all

    I have a question about contextual menus in the Font Overview, as documented here. (so useful!! thanks)

    Was wondering, is there any way to dynamically/contextually toggle either the visibility or the “enabled” state of the menu entries? I’m looking at a situation where not all menu entries are necessarily relevant or available depending on which glyph is selected, so being able to react to that would be super useful.

    Cheers
    Nina


  • admin

    oh, idd not working as it should be... will be fixed in next beta/release

    thanks



  • Ah cool, thanks Frederik.

    Hmm, I just tried this and setting an item to enabled=False like this does not directly have an impact — that item still looks like the others, and reacts to click too. Am I doing it wrong? (Looking at 3.3 build 1911061105)

    PS. What does work is just composing the myMenuItems list on the fly so the irrelevant options don’t show up at all, so that’s good in the meantime. Having greyed-out/disabled options might be a useful addition if possible. Thanks!


  • admin

    you can also provide a dict as menu item during the notification:

    myMenuItems = [
               dict(title="option 1", callback =self.option1Callback, enabled=False),
               ("option 2", self.option2Callback),
               ("submenu", [("option 3", self.option3Callback)])
           ]
    

    hope this helps!!