Answered
Can multiple lines of text in a pop-up window be automatically centered?
There are two situations here.
alert does not automatically center?
alert(“This is the first line\nAfter a line break, it cannot be centered and can only be spaced with spaces?”)
showDialog() cannot wrap lines? Only one line can be displayed.
showDialog(“Note: Please select an object. How to break lines here”, 1000);
//auto close dialog
showDialog(“Note: Please select an object. How to break lines here”, 1000);
function showDialog(message, duration) {
var win = new Window(“palette”, t, undefined, { closeButton: false });
win.add(“statictext”, undefined, message);
// Change font size It doesn't seem to work.
win.graphics.font = ScriptUI.newFont(“Heiti”, ScriptUI.FontStyle.BOLD, 20);
win.layout.layout(true); // Force layout before showing
win.show();
win.update(); // Force redraw before sleep
$.sleep(duration); // Wait for the specified duration
win.close(); // Then close the window
}
