Bug? [BANano][Solved] Multiline string in "Text" not correctly escaped from the Designer?

Toky Olivier

Active Member
Licensed User
Longtime User
Hi,
I think it's a bug. When I put multi-line string in a the designer, there is an exception in the console and the project is not run in the browser.
2022-04-06 19_18_54-Éditeur multilignes.png


Error in the browser:
2022-04-06 19_09_48-VKPAE - B4J.png


Transpiled JS:
2022-04-06 19_19_50-VKP Auto-Ecole.png


Thank you.
 

alwaysbusy

Expert
Licensed User
Longtime User
It is not really a bug, but a known limitation. It is hard for the Transpiler to know what you really want. E.g. if it results in html, then it would mean replacing the enters with <br>. But if it is something like a inline style, then they should be removed etc...

Things like this e.g. in the Style property will also not work:
B4X:
cursor: pointer;
width: 70px;
float: left;

You will need to write it in one line:
B4X:
cursor: pointer;width: 70px;float: left;

Therefor, you will have to handle this yourself and should never use multiple lines. Unfortunately, I don't have control over the IDE as for BANano, I would be better if this window did not exist as a multiline box.

So, in your case, writing this would probably solve it (if text is set as innerHTML):
B4X:
Mot de passe:<br>Test in new Line

I know it is no ideal, but I have to work within the boundaries given by the B4X IDE and sometimes it needs additional 'rules' specific for BANano apps.

Alwaysbusy
 

Toky Olivier

Active Member
Licensed User
Longtime User
But one thing strange is, it's working for RawHTML:
2022-04-06 20_56_00-Éditeur multilignes.png


And the result:
2022-04-06 20_56_24-VKP Auto-Ecole.png


So for RawHTML, it accepts multilines.

In setHTML code, I do it like you did for SKLabel:
B4X:
Public Sub setRawHTML(value As String)
    If mElement <> Null Then
        mElement.SetHTML(value)
    End If
    mRawHTML = value
End Sub

Public Sub getRawHTML() As String
    Return mRawHTML
End Sub

I don't understand what's happenning here.
 

Toky Olivier

Active Member
Licensed User
Longtime User
When I look the transpiled JS file (for the text from the designer):
2022-04-06 21_07_01-C__laragon_www_VKPAE_scripts_app1649239564346.js - Notepad++.png

But If I set Styles for example:
2022-04-06 21_10_10-C__laragon_www_VKPAE_scripts_app1649239766654.js - Notepad++.png

I see that carriage return & line feed are not replaced by "\r\n", that causes the problem. But it's in B4J Designer level or BANano?
 

Toky Olivier

Active Member
Licensed User
Longtime User
@alwaysbusy , I found the trick, we just need to put "Raw" in the Key of the Property
B4X:
#DesignerProperty: Key: RawStyle, DisplayName: Style, FieldType: String, DefaultValue: , Description: Styles added to the HTML tag. Must be a json String.

Now Style accepts multiline too:
2022-04-06 21_31_05-Éditeur multilignes.png


And It works as expected:
2022-04-06 21_31_44-VKP Auto-Ecole.png


So @Erel have put it like that I think. Or it's a bug? I don't know but Now it's fine, it's working.
 
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
It is done by BANano, not Erel. It is one of these inner tricks BANano uses (like the [BANRAW] trick). Looking at the BANano source code if either the key in the designer starts with 'raw' (like you said), or the value starts with '[BANRAW]', it will replace the enters. (\n has to become \\n for example, \r -> \\r, a double quote \\\").

Another one of these 'inner' tricks is the [BANCLEAN] prefix. This one will simply remove all enters.

Alwaysbusy
 
Last edited:

Toky Olivier

Active Member
Licensed User
Longtime User
It is done by BANano, not Erel. It is one of these inner tricks BANano uses (like the [BANRAW] trick). Looking at the BANano source code if either the key starts with 'raw' (like you said), or the value starts with '[BANRAW]', it will replace the enters. (\n has to become \\n for example, \r -> \\r, a double quote \\\").

Another one of these 'inner' tricks is the [BANCLEAN] prefix. This one will simply remove all enters.

Alwaysbusy
Okay, thank you. So the rule "never use multi line" can be overriden with this. It's fine as it opens to many possibilities, for eg.: Add multi-line text for a property "Options" => Set options for a Select-box etc...
 
Top