How to terminate a grid layout in MEL?

How to terminate a grid layout in MEL?

Anonymous
Not applicable
618 Views
1 Reply
Message 1 of 2

How to terminate a grid layout in MEL?

Anonymous
Not applicable

So I'm trying to create a UI in Melscript. I would like to go from a 6x6 grid of buttons to a single column of buttons with a width of the total grid (so if each button in the grid is 70x70, the new button has a width of 420). However, I'm having trouble transitioning out of the gridLayout command.

 

I've tried defining the size of the grid array with the  numberOfRowsColumns flag, but adding a new button just continues the grid. Same problem if I create a new grid that is 1x1. If I set autoGrow to false, the next button won't be added at all.

 

Here's what I have so far:

 

 

proc showTheWindow(){
    int $dev = 0;
    if ($dev && `window -exists "theWindow"`){
        deleteUI -window "theWindow";
    }
    if (!`window -exists "theWindow"`){
        window -title "Window"  "theWindow";
        columnLayout -adjustableColumn true;
        
        
        separator;

        gridLayout -numberOfRowsColumns 6 6 -cwh 70 70 -ag false;
        
    	for ($i = 0; $i<36; $i++){
    	    button -label "Grid Button" -command (/*a secret function(i)*/);
    	}
            
        separator;
        button -label "Regular Button";
        
        setParent ..;
        showWindow "theWindow";
    }    
}

showTheWindow();

 

 

And here's a gorgeous MS paint illustration of what I would like to achieve. Any help at all would be appreciated.

kimzeyjanelle_0-1587331153383.png

 

 

 

0 Likes
619 Views
1 Reply
Reply (1)
Message 2 of 2

jmreinhart
Advisor
Advisor
proc showTheWindow(){
    int $dev = 0;
    if ($dev && `window -exists "theWindow"`){
        deleteUI -window "theWindow";
    }
    if (!`window -exists "theWindow"`){
        window -title "Window"  "theWindow";
        columnLayout -adjustableColumn true;
        
        
        separator;

        gridLayout -numberOfRowsColumns 6 6 -cwh 70 70 -ag false;
    
    	for ($i = 0; $i<36; $i++){
    	    button -label "Grid Button";
    	}
    	setParent ..;
            
        separator;
        button -label "Regular Button";
        
        setParent ..;
        showWindow "theWindow";
    }    
}

showTheWindow();

setParent ..; means you that the previous active layout will be parent. So when you create the last button the previous active layout was the grid so the button gets added to the grid (which is already full). To fix this just add setParent ..; after creating the grid buttons but before creating the last button. That way grid and the last button will be parented to the window.

 

setParent is one of those annoying things you need to deal with while working with MEL UIs.

0 Likes