Adaptive layout for ScriptUI
I'm making a fairly simple two-button interface in ExtendScript and I want to make it so that if the window is horizontal, two buttons will stack side by side and fill the whole window, and if the window is vertical – one would be on top of the other.
Right now I'm trying to use use .onResizing and .onResize functions for Window object:
w.onResizing = w.onResize = function () {
this.layout.resize ();
}
But even though I define a function like this:
var drawBttns = function(){
var g = w.add ('group');
if(w.size[0] < w.size[1]){
g.orientation = 'column'
}
else{
g.orientation = "row"
}
g.alignment = ['right', 'top'];
g.alignChildren = 'fill';
g.add ('button {text: "b1"}');
g.add ('button {text: "b2"}').onClick = function(){
w.close()
}
}
It won't redraw on resize. Any ideas?