I have a button that I am creating with textOnly set to TRUE, but when I click on it in the simulator I am getting the following error:
File: bad argument #1 to ‘unpack’ (table expected, got nil)
Bad argument #1 to ‘unpack’ (table expected, got nil)
stack traceback:
[C]: in function ‘unpack’
?: in function ‘_setState’
?: in function ‘?’
?: in function <?:224>
?: in function <?:218>
My button is created as (it is created relative an object called textBox):
local btnClose = widget.newButton
{
id = “btnClose”,
height = 25,
width = 25,
x = textBox.x + (textBox.width/2) - 25,
y = textBox.y - (textBox.height/2) + 25,
label = “X”,
labelColor =
{
default = { .8, 0, 0 },
},
font = native.systemFontBold,
fontSize = 24,
emboss = true,
onPress = buttonHandler,
textOnly = true
}
The button handler:
local function buttonHandler(event)
if event.phase == “ended” then
if (event.target.id == “btnClose”) then
– execute code here
end
end
end
It works find if I do not set textOnly to true, however there is a small gray box where the button is drawn on my Android device (no testing on iOS yet)
I tried adjusting the handler but the error is happening before the handler is called…it seems to be internal to the button widget, so is there some other settings I could try?
Thank you!