I'm essentially trying to solve the same issue as in this post in Adobe forums. The solution there does not work very reliably. It specifically seems to fail in Photoshop. I need it to work in all apps.
This code below is a little test case where I was trying to figure out a way to make sure the height is calculated based on the content height, but it's not doing anything. I figured I should somehow reset the height... but that doesn't seem possible.
Any ideas?
Code: Select all
var dialog = new Window("dialog");
dialog.margins = 0;
var statictext1 = dialog.add("statictext", undefined, undefined, {multiline: true});
statictext1.text = "Vivamus a enim pretium, posuere lorem ac, suscipit ipsum. Quisque eget tempus ligula, nec porta erat. Curabitur facilisis tristique dui at suscipit. Sed sit amet feugiat sem. Aenean viverra, ligula sed finibus blandit, leo justo vulputate tellus.";
dialog.onShow = function() {
$.writeln('- - - - - - - -');
$.writeln( 'Width (before): ' + statictext1.bounds.width );
$.writeln( 'Height (before): ' + statictext1.bounds.height );
statictext1.size.width = 338;
dialog.layout.layout(true);
// dialog.layout.resize();
$.writeln('→');
$.writeln( 'Width (after): ' + statictext1.bounds.width );
$.writeln( 'Height (after): ' + statictext1.bounds.height );
};
dialog.show();