Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

setParent [-defineTemplate string] [-menu] [-topLevel] [-upLevel] [-useTemplate string] [string]

setParent is undoable, queryable, and NOT editable.

This command changes the default parent to be the specified parent. Two special parents are "/" which indicates the top of the hierarchy, or ".." which indicates one level up in the hierarchy. Trying to move above the top level has no effect.

A control must be parented to a control layout. A control layout may be parented to another control layout or a window. A menu may be parented to a window or a menu bar layout. For all of these cases the setParent command (with no flags) will indicate the current default parent.

A menu item must be parented to a menu. To specify the default menu parent use the command setParent -m/menu. Note that all menu item objects created using the -sm/subMenu may also be treated as menu objects.

The default parent is ignored by any object that explicitly sets the -p/parent flag when it is created.

Return value

stringName of the parent if the parent changes. Empty string if the parent doesn't change.

In query mode, return type is based on queried flag.

Flags

defineTemplate, menu, topLevel, upLevel, useTemplate
Long name (short name) Argument types Properties
-upLevel(-u) create
Move up one level in the hierarchy. Equivalent to use ".."
-topLevel(-top) create
Move to the top level in the hierarchy. Equivalent to use "/"
-menu(-m) createquery
Parent menu for menu items.
-defineTemplate(-dt) string create
Put a command in a mode where any other flags and args are parsed and added to the command template with the given name. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template.
-useTemplate(-ut) string create
Will force the command to use a command template given by the name other than the current one.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

//  Create a window with a menu bar and two menu bar layouts.
//
string $window = `window -menuBar true -widthHeight 300 200`;
string $fileMenu = `menu -label "File"`;
menuItem -label "Open";
paneLayout -configuration "vertical2";
string $leftMenuBarLayout = `menuBarLayout`;
string $leftMenu = `menu -label "Left"`;
menuItem -label "One";
setParent ..;
menuBarLayout;
menu -label "Right";
string $rightSubMenu = `menuItem -label "Colors" -subMenu true`;
setParent ..;
showWindow $window;
//  Add item to the "File" menu.
//
setParent -menu $fileMenu;
menuItem -label "Save";
//  Add item to the "Left" menu, explicitly ignore default parent
//    by setting -p/parent flag.
//
menuItem -parent $leftMenu -label "Two";
//  Add more items to the "File" menu because it is still the
//    default parent.
//
menuItem -divider true;
menuItem -label "Close";
//  Add another menu to the left menu bar layout.
//
setParent $leftMenuBarLayout;
menu -label "Middle";
menuItem -label "Three";
//  Add items to right sub menu.
//
setParent -menu $rightSubMenu;
menuItem -label "Red";
menuItem -label "Blue";
menuItem -label "Green";