B4J Question [BCTextEngine] BBLabel WordWrap does not work

Alexander Stolte

Expert
Licensed User
Longtime User
I need the WordWrap feature if the text is too long for the width of the label. Unfortunately, it writes the text in the area that is no longer visible. Is this a bug or am I using the BBLabel incorrectly?

B4X:
    BBLabel1.TextEngine = TextEngine
    BBLabel1.WordWrap = True
    BBLabel1.Text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."

1735167197503.png


Example Project is in the attachment
 

Attachments

  • BBLabel WordWrap.zip
    8.9 KB · Views: 9

PaulMeuris

Well-Known Member
Licensed User
1735180109240.png

On the left with the yellow border is the BBLabel (a lightweight label as @Erel calls it in: bbcodeview and textengine )
On the right with the red border is a normal Label.
The labels have an alignment TOP_LEFT and a Wrap Text checked in the designer.
The wrap text works but the text is too long for the label.
A normal label will truncate the text and add ... at the end, the BBLabel doesn't do that.
Maybe you could have a look into the property settings of the TextEngine that is being used.

EDIT: when you use a BBCodeView a scrollbar will appear if the text is too long.
1735184986845.png


EDIT 2: the height of the BBLabel can be adjusted to the length of the text.
1735186858289.png

The code for this you can find in: BBLabel real height (uncheck handle resize event in the layout).
B4X:
    BBLabel1.Text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
    Dim TextHeight As Int = BBLabel1.Paragraph.Height / TextEngine.mScale  + BBLabel1.Padding.Top + BBLabel1.Padding.Bottom
    BBLabel1.mBase.Height = TextHeight
Of course this can only be done if there is room to let the BBLabel expand. (i had to move the BBCodeView to the right)
 
Last edited:
Upvote 1
Top