Hi Brent,
No problem. Thanks for getting back to me…
Okay - the buttons in the screenshot below all have the exact same y position set but the first one has a verticalTextOffset of 50 (I made it extreme to show the problem but even values as small as 5 cause the problem if the font is one with a large bounding area).
As you can see, the text is offset, but the button has been offset too.
I presume this is because the overall height of the button has changed and therefore the y position appears different when it’s actually the same? Is that what’s happening?
My code is just standard widget button code - nothing altered…
local buttonImageData = ButtonImageData:getButtonImageData(); local imageSheet = graphics.newImageSheet( "btn-bg.png", buttonImageData ) btn = widget.newButton { width = params.w, height = params.h, label = params.txt, labelAlign = "center", labelYOffset = params.verticalTextOffset, emboss = false, font = params.fontName, fontSize = params.fontSize, labelColor = { default = params.textCol, over = params.textColOver, }, sheet = imageSheet, topLeftFrame = 1, topLeftOverFrame = 10, middleLeftFrame = 2, middleLeftOverFrame = 11, bottomLeftFrame = 3, bottomLeftOverFrame = 12, topMiddleFrame = 4, topMiddleOverFrame = 13, middleFrame = 5, middleOverFrame = 14, bottomMiddleFrame = 6, bottomMiddleOverFrame = 15, topRightFrame = 7, topRightOverFrame = 16, middleRightFrame = 8, middleRightOverFrame = 17, bottomRightFrame = 9, bottomRightOverFrame = 18, onEvent = handleButtonEvent } local layer = params.layer or interfaceLayer; layer:insert( btn, true ); btn.x = params.px; btn.y = params.py; btn.anchorX = 0.5; btn.anchorY = 0.5
I tried changing the anchorY to 0 but because the font’s bounding area spills out of the top and the bottom of the button, it still appears offset.
Any help would be much appreciated.
Thanks,
Ian