Dynamic MenuItem Updates

Hey, I've got a basic Python RV package that sets up a nested menu structure. Right now the menu items are just created on-load, which actually slows the RV launch time by a few seconds. I'm was hoping I could just set up a function to generate the menu contents as the user highlights the parent menu item, but I don't see anything in the documentation about modifying/creating menu items outside of the Mode's initialization process. Is there any way to do this?




  • 0
    Ray K

    I got an answer, so for anyone else in the future:


    Hi Ray,

    You have two options to get what you are after. Option one is to call the code that builds your mode's menus directly at a time of your choosing.

    That is through commands.defineModeMenu(modeName, menu). Where modeName is the string name of your mode, and menu is the menu structure of tuples you have been building in your current mode init.

    The second approach, and more likely the one you are after, is to "delay" load your package/mode rather than loading it immediately. You can change this setting in the PACKAGE file for your mode. Simply set the modes: load: value to delay. Here is the documentation about that.


    The idea behind delay loading your package is that you put off all of the work you package requires to get setup from the launch of RV until a user actually requests some part of your mode/package. This is how the session manager works as well as the annotation mode.

    This is the PACKAGE mode: settings for the annotation mode:

    - file: annotate_mode.mu 
    menu: Tools/Annotation 
    shortcut: 'F10' 
    event: 'key-down--f10' 
    load: delay

    When the Tools/Annotation menu is picked or F10 is pressed this mode is loaded.

    I think that might be more like what you want. In either case, please let me know if I can provide you with any more information to get set up.


    Jon Morley