Button labelAlign bug

I just found that on a button of a circle shape labelAlign is always left if the label has “\n” in it.

local close_menu_button = widget.newButton({
		x = display.contentCenterX,
		y = display.contentCenterY,
       	id = "close",
       	label = "My\nProfile", -- if you remove "\n" it will be centered by default
		shape = "circle",
		radius = 50,
		fontSize = display.contentWidth/15,
		labelAlign = "center" -- does not work if "\n" is present
    	})

That might not be a bug.

The widget library was written ages ago and I think that it is using the old syntax for newText(), which means that it doesn’t properly support multi-line texts.

If that’s the case, the the labelAlign property would probably just mean that it’s the label itself, i.e. the display object which is created, that is aligned to the left, center or right of the button, but the text in the text object itself is always left aligned.

You wouldn’t notice this unless you tried creating multi-line texts, like you’ve done now. You can check if that’s the case from the widget framework source code. Then, if I’m right, and if you need multi-line labels, you (or someone) would need to add support for them.

1 Like