You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Erik Innocent <ei...@gmail.com> on 2013/08/22 01:07:37 UTC

How to express a newline in a Label within BXML?

Thanks everyone for your help so far! I've yet another question.

How do I place a newline in a Label's text in BXML? I see that in 2.0.3,
Pivot began supporting text labels with hard newlines with the "\n"
character (
http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C20130122010418.3EC4223889F7@eris.apache.org%3E),
but this seems only to work programmatically.

As a workaround, I've tried the following things, which all fail:

   - Placing "\n" as the value of the text attribute in the label in BXML.
   This shows up as "\n" in the application, and "\\n" when viewing the
   label.getText() result
   - Using "\\n" as the value instead, in hopes that the double backslash
   might escape. It does not, and the label text appears as "\\n" in the app.
   - Doing label.setText(label.getText()) with 'text="\n" in BXML'. Doesn't
   work because the "\n" is already escaped to "\\n". I suppose I could do a
   replace of "\\" with "\" before setText(), but it seems inelegant to have
   to initialize all labels like this.

Other than setting the label programmatically, any tips? Note that setting
the value programmatically does work for me. I've got "wrapText:true" set
in my tests.

Thanks!
--E

Re: How to express a newline in a Label within BXML?

Posted by Sandro Martini <sa...@gmail.com>.
Roger, thanks for the quick trick and commit :-) ...

Bye


2013/8/22 Roger L. Whitcomb <Ro...@actian.com>:
> Great!
>
>
>
> I’ve just now updated the “label_test.bxml” file in “trunk” so it has a
> couple of these hard-coded newlines just as an example for others.  To use
> it, navigate to the “tests/src/org/apache/pivot/tests” directory and do:
> “java org.apache.pivot.wtk.ScriptApplication --src=.\label_test.bxml”
>
>
>
> ~Roger
>
>
>
> From: Erik Innocent [mailto:einnocent@gmail.com]
> Sent: Thursday, August 22, 2013 9:35 AM
> To: user
> Subject: Re: How to express a newline in a Label within BXML?
>
>
>
> It works for me! The answer seems kind of obvious, in retrospect =)
>
>
>
> Thanks!
>
> --E
>
>
>
>
>
> On Thu, Aug 22, 2013 at 11:10 AM, Roger Whitcomb
> <Ro...@rbwhitcomb.com> wrote:
>
> So to set a newline in a bxml file you have to use the XML escape
> mechanism(s). That's all. For example: &#10; or &#x0A;
>
> ~Roger Whitcomb
>
> Sent from my iPhone
>
>
> On Aug 22, 2013, at 3:00 AM, Sandro Martini <sa...@gmail.com>
> wrote:
>
>> Hi Erik,
>> you have reason, currently I find multiline label samples only in
>> LabelTest.java class, I have to add a bxml version of it ...
>> Searching in our sources, I find other examples for multiline strings
>> (in bxml files), but for other components (TableView, and related
>> renderers), like: table_pane_test2.bxml, table_pane_test4.bxml ... but
>> these could be a starting point. Could you do some tests starting from
>> here ?
>>
>> Anyway this could be a BXMLSerializer issue (LabelSkin does the line
>> splitting if it finds the \n snside the label text , but as a single
>> char), so we have to verify it.
>>
>> Roger, what do you think ?
>>
>> Let's update.
>>
>> Bye
>>
>> 2013/8/22 Erik Innocent <ei...@gmail.com>:
>>> Thanks everyone for your help so far! I've yet another question.
>>>
>>> How do I place a newline in a Label's text in BXML? I see that in 2.0.3,
>>> Pivot began supporting text labels with hard newlines with the "\n"
>>> character
>>>
>>> (http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C20130122010418.3EC4223889F7@eris.apache.org%3E),
>>> but this seems only to work programmatically.
>>>
>>> As a workaround, I've tried the following things, which all fail:
>>>
>>> Placing "\n" as the value of the text attribute in the label in BXML.
>>> This
>>> shows up as "\n" in the application, and "\\n" when viewing the
>>> label.getText() result
>>> Using "\\n" as the value instead, in hopes that the double backslash
>>> might
>>> escape. It does not, and the label text appears as "\\n" in the app.
>>> Doing label.setText(label.getText()) with 'text="\n" in BXML'. Doesn't
>>> work
>>> because the "\n" is already escaped to "\\n". I suppose I could do a
>>> replace
>>> of "\\" with "\" before setText(), but it seems inelegant to have to
>>> initialize all labels like this.
>>>
>>> Other than setting the label programmatically, any tips? Note that
>>> setting
>>> the value programmatically does work for me. I've got "wrapText:true" set
>>> in
>>> my tests.
>>>
>>> Thanks!
>>> --E
>>
>
>

RE: How to express a newline in a Label within BXML?

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Great!

 

I've just now updated the "label_test.bxml" file in "trunk" so it has a
couple of these hard-coded newlines just as an example for others.  To
use it, navigate to the "tests/src/org/apache/pivot/tests" directory and
do: "java org.apache.pivot.wtk.ScriptApplication
--src=.\label_test.bxml"

 

~Roger

 

From: Erik Innocent [mailto:einnocent@gmail.com] 
Sent: Thursday, August 22, 2013 9:35 AM
To: user
Subject: Re: How to express a newline in a Label within BXML?

 

It works for me! The answer seems kind of obvious, in retrospect =)

 

Thanks!

--E

 

 

On Thu, Aug 22, 2013 at 11:10 AM, Roger Whitcomb
<Ro...@rbwhitcomb.com> wrote:

So to set a newline in a bxml file you have to use the XML escape
mechanism(s). That's all. For example: &#10; or &#x0A;

~Roger Whitcomb

Sent from my iPhone


On Aug 22, 2013, at 3:00 AM, Sandro Martini <sa...@gmail.com>
wrote:

> Hi Erik,
> you have reason, currently I find multiline label samples only in
> LabelTest.java class, I have to add a bxml version of it ...
> Searching in our sources, I find other examples for multiline strings
> (in bxml files), but for other components (TableView, and related
> renderers), like: table_pane_test2.bxml, table_pane_test4.bxml ... but
> these could be a starting point. Could you do some tests starting from
> here ?
>
> Anyway this could be a BXMLSerializer issue (LabelSkin does the line
> splitting if it finds the \n snside the label text , but as a single
> char), so we have to verify it.
>
> Roger, what do you think ?
>
> Let's update.
>
> Bye
>
> 2013/8/22 Erik Innocent <ei...@gmail.com>:
>> Thanks everyone for your help so far! I've yet another question.
>>
>> How do I place a newline in a Label's text in BXML? I see that in
2.0.3,
>> Pivot began supporting text labels with hard newlines with the "\n"
>> character
>>
(http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C2
0130122010418.3EC4223889F7@eris.apache.org%3E),
>> but this seems only to work programmatically.
>>
>> As a workaround, I've tried the following things, which all fail:
>>
>> Placing "\n" as the value of the text attribute in the label in BXML.
This
>> shows up as "\n" in the application, and "\\n <file:///\\n> " when
viewing the
>> label.getText() result
>> Using "\\n <file:///\\n> " as the value instead, in hopes that the
double backslash might
>> escape. It does not, and the label text appears as "\\n <file:///\\n>
" in the app.
>> Doing label.setText(label.getText()) with 'text="\n" in BXML'.
Doesn't work
>> because the "\n" is already escaped to "\\n <file:///\\n> ". I
suppose I could do a replace
>> of "\\" with "\" before setText(), but it seems inelegant to have to
>> initialize all labels like this.
>>
>> Other than setting the label programmatically, any tips? Note that
setting
>> the value programmatically does work for me. I've got "wrapText:true"
set in
>> my tests.
>>
>> Thanks!
>> --E
>

 


Re: How to express a newline in a Label within BXML?

Posted by Erik Innocent <ei...@gmail.com>.
It works for me! The answer seems kind of obvious, in retrospect =)

Thanks!
--E



On Thu, Aug 22, 2013 at 11:10 AM, Roger Whitcomb <
RogerandBeth@rbwhitcomb.com> wrote:

> So to set a newline in a bxml file you have to use the XML escape
> mechanism(s). That's all. For example: &#10; or &#x0A;
>
> ~Roger Whitcomb
>
> Sent from my iPhone
>
> On Aug 22, 2013, at 3:00 AM, Sandro Martini <sa...@gmail.com>
> wrote:
>
> > Hi Erik,
> > you have reason, currently I find multiline label samples only in
> > LabelTest.java class, I have to add a bxml version of it ...
> > Searching in our sources, I find other examples for multiline strings
> > (in bxml files), but for other components (TableView, and related
> > renderers), like: table_pane_test2.bxml, table_pane_test4.bxml ... but
> > these could be a starting point. Could you do some tests starting from
> > here ?
> >
> > Anyway this could be a BXMLSerializer issue (LabelSkin does the line
> > splitting if it finds the \n snside the label text , but as a single
> > char), so we have to verify it.
> >
> > Roger, what do you think ?
> >
> > Let's update.
> >
> > Bye
> >
> > 2013/8/22 Erik Innocent <ei...@gmail.com>:
> >> Thanks everyone for your help so far! I've yet another question.
> >>
> >> How do I place a newline in a Label's text in BXML? I see that in 2.0.3,
> >> Pivot began supporting text labels with hard newlines with the "\n"
> >> character
> >> (
> http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C20130122010418.3EC4223889F7@eris.apache.org%3E
> ),
> >> but this seems only to work programmatically.
> >>
> >> As a workaround, I've tried the following things, which all fail:
> >>
> >> Placing "\n" as the value of the text attribute in the label in BXML.
> This
> >> shows up as "\n" in the application, and "\\n" when viewing the
> >> label.getText() result
> >> Using "\\n" as the value instead, in hopes that the double backslash
> might
> >> escape. It does not, and the label text appears as "\\n" in the app.
> >> Doing label.setText(label.getText()) with 'text="\n" in BXML'. Doesn't
> work
> >> because the "\n" is already escaped to "\\n". I suppose I could do a
> replace
> >> of "\\" with "\" before setText(), but it seems inelegant to have to
> >> initialize all labels like this.
> >>
> >> Other than setting the label programmatically, any tips? Note that
> setting
> >> the value programmatically does work for me. I've got "wrapText:true"
> set in
> >> my tests.
> >>
> >> Thanks!
> >> --E
> >
>

Re: How to express a newline in a Label within BXML?

Posted by Roger Whitcomb <Ro...@rbwhitcomb.com>.
So to set a newline in a bxml file you have to use the XML escape mechanism(s). That's all. For example: &#10; or &#x0A;

~Roger Whitcomb

Sent from my iPhone

On Aug 22, 2013, at 3:00 AM, Sandro Martini <sa...@gmail.com> wrote:

> Hi Erik,
> you have reason, currently I find multiline label samples only in
> LabelTest.java class, I have to add a bxml version of it ...
> Searching in our sources, I find other examples for multiline strings
> (in bxml files), but for other components (TableView, and related
> renderers), like: table_pane_test2.bxml, table_pane_test4.bxml ... but
> these could be a starting point. Could you do some tests starting from
> here ?
> 
> Anyway this could be a BXMLSerializer issue (LabelSkin does the line
> splitting if it finds the \n snside the label text , but as a single
> char), so we have to verify it.
> 
> Roger, what do you think ?
> 
> Let's update.
> 
> Bye
> 
> 2013/8/22 Erik Innocent <ei...@gmail.com>:
>> Thanks everyone for your help so far! I've yet another question.
>> 
>> How do I place a newline in a Label's text in BXML? I see that in 2.0.3,
>> Pivot began supporting text labels with hard newlines with the "\n"
>> character
>> (http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C20130122010418.3EC4223889F7@eris.apache.org%3E),
>> but this seems only to work programmatically.
>> 
>> As a workaround, I've tried the following things, which all fail:
>> 
>> Placing "\n" as the value of the text attribute in the label in BXML. This
>> shows up as "\n" in the application, and "\\n" when viewing the
>> label.getText() result
>> Using "\\n" as the value instead, in hopes that the double backslash might
>> escape. It does not, and the label text appears as "\\n" in the app.
>> Doing label.setText(label.getText()) with 'text="\n" in BXML'. Doesn't work
>> because the "\n" is already escaped to "\\n". I suppose I could do a replace
>> of "\\" with "\" before setText(), but it seems inelegant to have to
>> initialize all labels like this.
>> 
>> Other than setting the label programmatically, any tips? Note that setting
>> the value programmatically does work for me. I've got "wrapText:true" set in
>> my tests.
>> 
>> Thanks!
>> --E
> 

Re: How to express a newline in a Label within BXML?

Posted by Sandro Martini <sa...@gmail.com>.
Hi Erik,
you have reason, currently I find multiline label samples only in
LabelTest.java class, I have to add a bxml version of it ...
Searching in our sources, I find other examples for multiline strings
(in bxml files), but for other components (TableView, and related
renderers), like: table_pane_test2.bxml, table_pane_test4.bxml ... but
these could be a starting point. Could you do some tests starting from
here ?

Anyway this could be a BXMLSerializer issue (LabelSkin does the line
splitting if it finds the \n snside the label text , but as a single
char), so we have to verify it.

Roger, what do you think ?

Let's update.

Bye

2013/8/22 Erik Innocent <ei...@gmail.com>:
> Thanks everyone for your help so far! I've yet another question.
>
> How do I place a newline in a Label's text in BXML? I see that in 2.0.3,
> Pivot began supporting text labels with hard newlines with the "\n"
> character
> (http://mail-archives.apache.org/mod_mbox/pivot-commits/201301.mbox/%3C20130122010418.3EC4223889F7@eris.apache.org%3E),
> but this seems only to work programmatically.
>
> As a workaround, I've tried the following things, which all fail:
>
> Placing "\n" as the value of the text attribute in the label in BXML. This
> shows up as "\n" in the application, and "\\n" when viewing the
> label.getText() result
> Using "\\n" as the value instead, in hopes that the double backslash might
> escape. It does not, and the label text appears as "\\n" in the app.
> Doing label.setText(label.getText()) with 'text="\n" in BXML'. Doesn't work
> because the "\n" is already escaped to "\\n". I suppose I could do a replace
> of "\\" with "\" before setText(), but it seems inelegant to have to
> initialize all labels like this.
>
> Other than setting the label programmatically, any tips? Note that setting
> the value programmatically does work for me. I've got "wrapText:true" set in
> my tests.
>
> Thanks!
> --E
>
>
>