-
Dynamic orientation in dockable ui
Hi guys,
I am fine tuning the UI (dockable) of a script and I can’t find a way to set the orientation of my buttons dynamically.
What I want to do is quite simple, when the width of my window is smaller than the height, I want my buttons to be in a column. Otherwise in a row.I think I am quite close but it is not working.
Would be great if someone could help me with this!
Many thanks,
H.{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);res="group{alignment:['left', 'top'],\
myButton1: Button{text:'1'},\
myButton2: Button{text:'2'},\
myButton3: Button{text:'3'},\
myButton4: Button{text:'4'},\
}";myPanel.grp = myPanel.add(res);
myPanel.grp.myButton1.size=[30,30];
myPanel.grp.myButton2.size=[30,30];
myPanel.grp.myButton3.size=[30,30];
myPanel.grp.myButton4.size=[30,30];myPanel.layout.layout(true);
myPanel.grp.minimumSize = myPanel.grp.size;
myPanel.layout.resize();myPanel.onResizing = myPanel.onResize = function () {
myPanel.orientation = myPanel.size.width > myPanel.size.height ? 'row' : 'column';
myPanel.layout.resize ();
}
myPanel.onShow = function () {
myPanel.layout.resize ();
}return myPanel;
}var myScriptPal = myScript_buildUI(thisObj);
if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}myScript(this);
}
