Skip to main content
dublove
Legend
August 25, 2025
Answered

Can multiple lines of text in a pop-up window be automatically centered?

  • August 25, 2025
  • 1 reply
  • 192 views

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
}

 

1 reply

Peter KahrelCommunity ExpertCorrect answer
Community Expert
August 25, 2025
dublove
dubloveAuthor
Legend
August 25, 2025

Hi Peter Kahrel

Thank you very much.
It's a great book, but it's not very easy to read.
Is there a PDF version available?

Community Expert
August 25, 2025

It is a PDF. You can't have read it in any other way.