I am trying to create a replacement for the original alert function, because on Windows it shows as an "Script Alert", which confuses users (some of them think this is an error). This is what I am trying to do:
Code: Select allfunction alerta(title,header, msg) {
var imgFile = File("/Applications/Adobe\ Photoshop\ CS5/Plug-ins/Panels/Kwik/images/portrait.png");
var z = "dialog { alignChildren: 'right', orientation:'row', text: '', \
img: Image {}, \
header: Group {orientation: 'column', alignment:'left', \
s: StaticText {text: 'Name:', alignment:'left'}, \
msg: StaticText {text: 'Name:', alignment:'left',}, \
msgEmpty: StaticText {text: '', alignment:'left',}, \
cb: Button {text:'OK', name:'cancel', alignment: 'right'},\
} \
}";
zf = new Window (z);
zf.text = title
zf.header.s.text = header
zf.header.s.graphics.font = ScriptUI.newFont ("dialog", "Bold", 12)
zf.header.msg.text = msg
zf.header.msg.multiline = true
zf.img.image = imgFile;
zf.show()
}
alerta("Important Alert", "Pay Attention", "You must select blue. \rThen yellow!")
The problem is, the multiline does not work. In the message above, only "You must select blue." shows up. Any idea what am I doing wrong?
Thanks a lot!
Alex
Static text with multiline
-
Mike Hale
Static text with multiline
I can't show you how to fix it using resource strings but I think the problem is multiline is what Adobe calls a creation property and needs to be supplied when the control is defined/created. Adding it later doesn't work.
Code: Select allvar w = new Window ('dialog', 'title');
w.st = w.add('statictext',undefined,'');
w.st.multiline = true;// doesn't make the control multiline
w.st.text = 'You must select blue. \rThen yellow!';
w.show();
var w = new Window ('dialog', 'title');
w.st = w.add('statictext',undefined,'',{multiline:true});
w.st.text = 'You must select blue. \rThen yellow!';
w.show();
Code: Select allvar w = new Window ('dialog', 'title');
w.st = w.add('statictext',undefined,'');
w.st.multiline = true;// doesn't make the control multiline
w.st.text = 'You must select blue. \rThen yellow!';
w.show();
var w = new Window ('dialog', 'title');
w.st = w.add('statictext',undefined,'',{multiline:true});
w.st.text = 'You must select blue. \rThen yellow!';
w.show();
-
undavide
Static text with multiline
Strangely the following doesn't work:
Code: Select alls: StaticText {text: 'Name:', alignment:'left', properties: { multiline: 'true' } }, \
(tried multiline, Multiline, MultiLine, true, 'true' to no avail - wild guessing)
Davide
Code: Select alls: StaticText {text: 'Name:', alignment:'left', properties: { multiline: 'true' } }, \
(tried multiline, Multiline, MultiLine, true, 'true' to no avail - wild guessing)
Davide
-
Mike Hale
Static text with multiline
I guess when all else fails - read the manual.
Code: Select allmsg: StaticText {text: 'Name:', alignment:'left',properties:{multiline:true},}, \
Code: Select allmsg: StaticText {text: 'Name:', alignment:'left',properties:{multiline:true},}, \
-
cbourn
Static text with multiline
Code: Select allvar dlg = new Window ('dialog');
dlg.preferredSize = [200, 200];
var txt = dlg.add('statictext', undefined, 'Multiline Output\nSecond Line\nThird Line', {multiline: true});
txt.preferredSize = [200, 200];
Sizes are useful for word wrap customization.
dlg.preferredSize = [200, 200];
var txt = dlg.add('statictext', undefined, 'Multiline Output\nSecond Line\nThird Line', {multiline: true});
txt.preferredSize = [200, 200];
Sizes are useful for word wrap customization.
-
Mike Hale
Static text with multiline
You don't need the lineCode: Select alldlg.preferredSize = [200, 200];The ScriptUI auto layout will size the window to fit it's contents.
You can also specify just width or height if only one is neededCode: Select alltxt.preferredSize.height = 200;
And because of the default spacing around controls, auto layout will make the window larger than the specified 200,200 because you set the size of one of the controls to those values.
Finally setting the size is really only needed when you either don't set the text so auto layout can't determine the size, or if you are trying to fine tune auto layout.
You can also specify just width or height if only one is neededCode: Select alltxt.preferredSize.height = 200;
And because of the default spacing around controls, auto layout will make the window larger than the specified 200,200 because you set the size of one of the controls to those values.
Finally setting the size is really only needed when you either don't set the text so auto layout can't determine the size, or if you are trying to fine tune auto layout.