Center-Align Text Label Inside Widget

Greetings,

Let’s say I have the following widget:

[lua]local dialogueButtonOne = widget.newButton{
id = “dialogueButtonOne”,
label = dialogueButtonOneLabel,
onEvent = onDialogueButtonOneTouch,
fontSize = 14,
yOffset = -2,
labelColor = { default={ 65 }, over={ 0 } },
width = 80,
height = 60
}[/lua]

By default, it appears that the label-- “dialogueButtonOneLabel”, in this case-- aligns right. I want this text to always align to the center of the button/widget. How can I do this? Is there a Label Alignment property of widgets that I’m missing?

Thanks! [import]uid: 191085 topic_id: 33364 reply_id: 333364[/import]

I don’t see an option to edit my post (feature for subscribers only?), but I wanted to correct a mistake: by default, the text aligns left, not right. I want the text to align center, not left.

Thanks again. [import]uid: 191085 topic_id: 33364 reply_id: 132512[/import]

I don’t see an option to edit my post (feature for subscribers only?), but I wanted to correct a mistake: by default, the text aligns left, not right. I want the text to align center, not left.

Thanks again. [import]uid: 191085 topic_id: 33364 reply_id: 132512[/import]

It’s been about 3 days, and I haven’t been able to figure out a way to do this. Anyone have any suggestions/recommendations?

Thanks, again! [import]uid: 191085 topic_id: 33364 reply_id: 132961[/import]

It’s been about 3 days, and I haven’t been able to figure out a way to do this. Anyone have any suggestions/recommendations?

Thanks, again! [import]uid: 191085 topic_id: 33364 reply_id: 132961[/import]

It’s been a few days, and I haven’t had any luck with this. If no one has an answer for me, should I create a feature request, or is there a better way to contact the appropriate people? [import]uid: 191085 topic_id: 33364 reply_id: 133543[/import]

By default all Widget ‘labels’ are centered within the button. I think what is probably happening is that you are assigning new text to it without repositioning it or something else is affecting the placement. Either way, here is some code that should fix it:

[lua]local dialogueButtonOne = widget.newButton{
id = “dialogueButtonOne”,
label = dialogueButtonOneLabel,
onEvent = onDialogueButtonOneTouch,
fontSize = 14,
yOffset = -2,
labelColor = { default={ 65 }, over={ 0 } },
width = 80,
height = 60
}
–use the line below to center text
dialogueButtonOne.label.x = dialogueButtonOne.width / 2;[/lua]

If you are changing the text within the Widget button later, make sure you center the text again since the reference will likely change if the text’s width is different. [import]uid: 188754 topic_id: 33364 reply_id: 133684[/import]

It’s been a few days, and I haven’t had any luck with this. If no one has an answer for me, should I create a feature request, or is there a better way to contact the appropriate people? [import]uid: 191085 topic_id: 33364 reply_id: 133543[/import]

By default all Widget ‘labels’ are centered within the button. I think what is probably happening is that you are assigning new text to it without repositioning it or something else is affecting the placement. Either way, here is some code that should fix it:

[lua]local dialogueButtonOne = widget.newButton{
id = “dialogueButtonOne”,
label = dialogueButtonOneLabel,
onEvent = onDialogueButtonOneTouch,
fontSize = 14,
yOffset = -2,
labelColor = { default={ 65 }, over={ 0 } },
width = 80,
height = 60
}
–use the line below to center text
dialogueButtonOne.label.x = dialogueButtonOne.width / 2;[/lua]

If you are changing the text within the Widget button later, make sure you center the text again since the reference will likely change if the text’s width is different. [import]uid: 188754 topic_id: 33364 reply_id: 133684[/import]