Widget 2.0 Button - Multiline Label Text

Hi.

Anyone knows how can I have a multiline label text in a button (widget v2)? I was expecting that the label would be automatically broken in two lines if it exceeds the button widget but that did not happen.

    local butt = widget.newButton                 {                    left = 100,                    top = 100,                    width = 105,                    height = 38,                    label = "You were challenged again",                    labelAlign = "center",                    font = "Arial",                    fontSize = 12,                    labelColor = { default = {0,0,0}, over = {255,255,255} },                    onEvent = onButtonEvent                 }  

 

I doubt this will work, but try putting a \n in the string where you want it to break.  This will only work if its a multi-line text field and I suspect its not but it would be an easy thing to try.

Yeah… I already tried but that does not work…  well,so I think I will have to create a display.newText to put it in front of the a button image…

Thanks, Rob

Using label = “Line One\nTwo\nThree” worked for me, however the lines are all left-justified, with only “Line One” centred in the button.

[edit] On further investigation, I’ve found that ‘\n’ only works in the Windows simulator. It doesn’t have any effect in the Mac simulator or on real iOS or Android devices.

I doubt this will work, but try putting a \n in the string where you want it to break.  This will only work if its a multi-line text field and I suspect its not but it would be an easy thing to try.

Yeah… I already tried but that does not work…  well,so I think I will have to create a display.newText to put it in front of the a button image…

Thanks, Rob

Using label = “Line One\nTwo\nThree” worked for me, however the lines are all left-justified, with only “Line One” centred in the button.

[edit] On further investigation, I’ve found that ‘\n’ only works in the Windows simulator. It doesn’t have any effect in the Mac simulator or on real iOS or Android devices.

Hi.

It would be great if the button label can be upgraded to be able to support word wrapping and linebreaks.

I have suggestions that may resolve the problem in a future upgrade of the button widget :

  • The labelAlign may me transmitted as the new align option of the internal button text (instead of using it to align in the button view)

  • An option labelWidth may be added and transmitted as the width option of the label). Then the text will be automatically wrapped and the linebreaks ("\n") will be correctly interpreted by the display.

What do you think about it ? Did you already plan something like this for a future release ?

Hi.

It would be great if the button label can be upgraded to be able to support word wrapping and linebreaks.

I have suggestions that may resolve the problem in a future upgrade of the button widget :

  • The labelAlign may me transmitted as the new align option of the internal button text (instead of using it to align in the button view)

  • An option labelWidth may be added and transmitted as the width option of the label). Then the text will be automatically wrapped and the linebreaks ("\n") will be correctly interpreted by the display.

What do you think about it ? Did you already plan something like this for a future release ?

I would like to echo Positive84’s comments above. That would be a great upgrade for Widget Buttons. I was searching for this same solution.

I would like to echo Positive84’s comments above. That would be a great upgrade for Widget Buttons. I was searching for this same solution.

Same here :slight_smile:

Same here :slight_smile: