March 2019: ewertb.soundlinker.com is getting relocated to ewertb.mayasound.com, please update your bookmarks.

MEL How-To #22

Back · Previous · Next Maya

How can I add a control to the top of a UI layout instead of the bottom (as is the default)?

You have two options:

  1. Use a formLayout and re-attach the controls as you add each to the layout:

    formLayout myForm;
      text1;
      text2;
      text3;
    
    formLayout -e
      -attachForm     text1    top   4
      -attachControl  text2    top   4  text1
      -attachControl  text3    top   4  text2
        myForm;
    
    // and then..
    
    setParent myForm;
      text4;
    
    formLayout -e
      -attachForm     text4    top   4
      -attachControl  text1    top   4  text4
        myForm;
    
  2. Delete all children of the layout and re-add in the desired order:

    columnLayout myColumn;
      text1;
      text2;
      text3;
    
    // and then...
    
    string $children[] = `columnLayout -q -childArray myColumn`;
    for ( $child in $children )
      deleteUI $child;
    
    setParent myColumn;
      text4;
      text1;
      text2;
      text3;