Plugins.dialogs Strips Line Ends

Questions and answers on developing, deploying and using plugins and JavaBeans

Plugins.dialogs Strips Line Ends

Postby tkilshaw1553613063 » Fri Oct 18, 2024 12:14 am

When I pass a string with multiple line end characters in it, that is "\n" characters, when the text is displayed all the lines are shown without line breaks.

Is there any way to get for example plugins.dialogs.showInfoDialog( 'Information', multiLineString ) to display the text without stripping out the line end characters?

thanks,

Terry
tkilshaw1553613063
 
Posts: 56
Joined: Tue Mar 26, 2019 5:11 pm

Re: Plugins.dialogs Strips Line Ends

Postby robert.edelmann » Fri Oct 18, 2024 2:07 am

In NG / TiNG you can use <br/> and other tags to format your Dialog.
Code: Select all
function dialogTest() {
   plugins.dialogs.showInfoDialog('titel','message<br/>spanning<br/>several<br/>lines.');
   // alternative
   var message = 'message with\nbreaks.';
   plugins.dialogs.showInfoDialog('titel',utils.stringReplace(message,'\n','<br/>\n'));
}
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 118
Joined: Wed Aug 14, 2013 6:12 pm

Re: Plugins.dialogs Strips Line Ends

Postby tkilshaw1553613063 » Fri Oct 18, 2024 5:19 pm

Thanks Robert!

This has saved me a great deal of work. A couple of questions still remain:

- why are the \n characters being kept. Why not "<br/>" rather than "<br/>\n"?

- can any other HTML elements be used here too?

again my thanks and gratitude!

Terry
tkilshaw1553613063
 
Posts: 56
Joined: Tue Mar 26, 2019 5:11 pm

Re: Plugins.dialogs Strips Line Ends

Postby robert.edelmann » Fri Oct 18, 2024 6:30 pm

I keep the newline around due to force of habit and backwards compatibility, I think it worked in smarclient and ng the same way then. We moved away from smartclient, so I can't really test anymore.

You can use other elements, some of them look off in certain clients (<b> looks off on my mac at least, <i> is fine), we use <b> and <i> for our use case.
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 118
Joined: Wed Aug 14, 2013 6:12 pm

Re: Plugins.dialogs Strips Line Ends

Postby tkilshaw1553613063 » Fri Oct 18, 2024 6:37 pm

My thanks again.

all the best,

Terry
tkilshaw1553613063
 
Posts: 56
Joined: Tue Mar 26, 2019 5:11 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 7 guests