Go to: Synopsis. Return value. MEL examples.

Synopsis

saveMenu string string

saveMenu is undoable, NOT queryable, and NOT editable.

This command is used for saving the contents of a menu, so that another instance of the menu may be recreated later. The command writes out a file which, when run as a script, will rebuild the menuItems contained in the original menu. Note that the fileName is relative to the user's marking menu preference directory.

Note that this command is used solely by the Marking Menu Editor and is not intended to be used for general purposes.

Note that this command doesn't work well with controls that have mixed mel and python command callbacks. Also, because it saves the menu state to a mel file, it does not work with callbacks that are python callable objects.

The first argument is the name of the manu to save, the second one is the name of the file.

Return value

stringThe name of the saved file.

MEL examples

// Create a window with two frames.
//
string $win = `window -t "saveMenu Example"`;
columnLayout;
string $frame1 = `frameLayout
    -h 90
    -l "Original Menu (LMB)"`;

    text -l "(click here)";
setParent ..;
string $frame2 = `frameLayout
    -h 90
    -l "Copy of Original (LMB)"`;

    text -l "(click here)";
setParent ..;

// Create a menu.
//
string $menu1 = `popupMenu
    -parent $frame1
    -b 1
    -mm true`;

    menuItem -rp "N" -l "Up";
    menuItem -rp "S" -l "Down";
    menuItem -rp "E" -l "Right";
    menuItem -rp "W" -l "Left";
    menuItem -label "Warm" -sm true;
        menuItem -l "Red";
        menuItem -l "Orange";
        menuItem -l "Yellow";
    setParent -m ..;
    menuItem -label "Cold" -sm true;
        menuItem -l "Green";
        menuItem -l "Blue";
        menuItem -l "Indigo";
        menuItem -l "Violet";
    setParent -m ..;
setParent -m ..;

// Save the menu to a file.
//
string $result = `saveMenu $menu1 menu_example`;

// Use the file to rebuild another instance of the menu.
//
string $menu1 = `popupMenu
    -parent $frame2
    -b 1
    -mm true`;
eval ("source \"" + `internalVar -userMarkingMenuDir` + "menu_example.mel\"");

// Finish up.
print ("The menu was saved in [" + `internalVar -userMarkingMenuDir` + $result + "]\n");
showWindow $win;