Change the size of a dialog window based on an action in ScriptUI

1.7k views Asked by At

ScriptUI is wonderful, but seems to have some limitations. I am looking for an ability to dynamically resize a dialog window based on an action taken on one of the controls inside of it, such as an .onClick() or .onShow() callback. However, the only way I've seen for the window to be resized is before it is drawn on the screen with the .show() method. Once the window has been shown, it appears that there is no way for a control to resize it. Please tell me I am wrong and there is a way to do this.

1

There are 1 answers

1
fabianmoronzirfas On BEST ANSWER

Mostly based on Peter Kahrels ScriptUI Guide

var w = new Window ("dialog"); 
var b = w.add('button',undefined,'Click me');
var small = false;
//~ w.onShow = function () {
//~     w.size = {width: 300, height: 400};
//~     } 
b.onClick = function(){
    small = !small;
    if(small == false){
        w.size = {width: 300, height: 400};
    }else{
        w.size = {width: 100, height: 100};
    }
}
w.show();