Copy link to clipboard
Copied
Hi everyone
I want to make a script which contains a list of buttons and make the orientation dynamically adapted to the panel resize action. And I found a way in ScriptUI for Dummies doc.
This works as expected:
w = new Window('palette', 'Test', undefined, { resizeable: true });
w.alignChildren = ['left', 'top'];
w.orientation = 'row';
w.add('button {text: "1",preferredSize:[32,32]}');
w.add('button {text: "2",preferredSize:[32,32]}');
w.add('button {text: "3",preferredSize:[32,32]}');
w.add('button {text: "4",preferredSize:[32,32]}');
w.add('button {text: "5",preferredSize:[32,32]}');
w.layout.layout(true);
w.layout.resize();
w.onResizing = w.onResize = function () {
w.orientation = w.size.width > w.size.height ? 'row' : 'column';
w.layout.resize();
}
w.onShow = function () {
w.layout.resize();
}
w.show();
But typically I use resource string. In the resource string way, the orientation doesn't change. Code below:
w = new Window('palette', 'Test', undefined, { resizeable: true });
var res =
"Group{alignChildren:['left','top'],\
bt1: Button{text: '1',preferredSize:[32,32]},\
bt2: Button{text: '2',preferredSize:[32,32]},\
bt3: Button{text: '3',preferredSize:[32,32]},\
bt4: Button{text: '4',preferredSize:[32,32]},\
bt5: Button{text: '5',preferredSize:[32,32]},\
}"
var mainGrp = w.add(res);
// w.alignChildren = ['left', 'top'];
// w.orientation = 'row';
// w.add('button {text: "1",preferredSize:[32,32]}');
// w.add('button {text: "2",preferredSize:[32,32]}');
// w.add('button {text: "3",preferredSize:[32,32]}');
// w.add('button {text: "4",preferredSize:[32,32]}');
// w.add('button {text: "5",preferredSize:[32,32]}');
w.layout.layout(true);
w.layout.resize();
w.onResizing = w.onResize = function () {
w.orientation = w.size.width > w.size.height ? 'row' : 'column';
w.layout.resize();
}
w.onShow = function () {
w.layout.resize();
}
w.show();
You can see it does't change orientation:
What do I need to do to make this work in resource string way?
Have something to add?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more