Page 1 of 1

Linebreak in a TextGadget

Posted: Sat May 23, 2015 1:22 pm
by Little John
Hi,

I tested the following code both with PB 5.31 on Windows, and with SB 1.02 on Windows (with Firefox):

Code: Select all

If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   TextGadget(0, 10,  10, 150, 40, "Line 1 " + #CR$   + "Line 2")
   TextGadget(1, 10,  60, 150, 40, "Line 1 " + #LF$   + "Line 2")
   TextGadget(2, 10, 110, 150, 40, "Line 1 " + #CRLF$ + "Line 2")
EndIf

CompilerIf #PB_Compiler_OS <> #PB_OS_Web
   Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CompilerEndIf
Output with PureBasic (as expected):
Line 1
Line 2

Line 1
Line 2

Line 1
Line 2
Output with SpiderBasic:
Line 1 Line 2


Line 1 Line 2


Line 1 Line 2
So how can I force a linebreak in a TextGadget with SpiderBasic?

Re: Linebreak in a TextGadget

Posted: Sat May 23, 2015 2:23 pm
by Sirius-2337
HTML uses "<br>" for Line Breaks

Code: Select all

If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   TextGadget(0, 10,  10, 150, 40, "Line 1 " + "<br>"   + "Line 2")
EndIf

CompilerIf #PB_Compiler_OS <> #PB_OS_Web
   Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CompilerEndIf

Re: Linebreak in a TextGadget

Posted: Sat May 23, 2015 5:47 pm
by Little John
Uuuh, I didn't know that we have to ( in other words: "can" :-) ) use HTML tags in the text of a SpiderBasic TextGadget.
Many thanks for the info!

But the code that you posted above does not work with PureBasic. So we have to use CompilerIf just in order to use the proper line break.
SpiderBasic could translate #LF$ itself to <b>, that would make our PB code more compatible with SB (which is an imortant part of SpiderBasic's concept, as far as I understood).

Anyway, my problem is solved. Thanks again!

Re: Linebreak in a TextGadget

Posted: Sat May 23, 2015 8:45 pm
by skywalk
I thought SpiderBasic would convert string contents generated from PureBasic syntax to display properly in the browser? Is this a bug, or do I have to mix and match html markup in my code.

Re: Linebreak in a TextGadget

Posted: Mon May 25, 2015 8:22 am
by Fred
I think in this particular case, it would be easier for anyone to have the LF converted to <br> automatically

Re: Linebreak in a TextGadget

Posted: Mon Jan 25, 2016 12:34 pm
by Fred
After more thoughs, I think it's better to leave it as is, it's a particularity of web to have <br> instead of #CRLF$, like Linux has LF$ instead of CRLF$. Introducing automatic conversion could tends to incorrect results if you explicitely want to have <br> in it.