Go to: Synopsis. Return value. Flags. MEL examples.
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 level layout of the window 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.
string | Name 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.
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
-defineTemplate(-dt)
|
string
|
![]() |
||
|
||||
-menu(-m)
|
|
![]() ![]() |
||
|
||||
-topLevel(-top)
|
|
![]() |
||
|
||||
-upLevel(-u)
|
|
![]() |
||
|
||||
-useTemplate(-ut)
|
string
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
// 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";