I’m getting an error when I tried to insert a button widget to a scrollview widget and use an onEvent listener for the button.
Here is the error:
[lua]
Attempt to compare number with nil
stack traceback:
[C]: ?
?: in function ‘_isWithinBounds’
?: in function <?:135>
?: in function ‘dispatchEvent’
?: in function <?:267>
?: in function <?:218>
[/lua]
here is my sample code:
[lua]
local function moveEvent(event)
if (event.phase == “move”) then
– do something here
elseif(event.phase == “release”) then
– do something here
end
end
local scroll = widget.newScrollView
{
top = 120,
left = 20,
width = 600,
height = 650,
scrollWidth = 600,
scrollHeight = 650,
maskFile = “mask.png”,
horizontalScrollDisabled = false,
hideBackground = true
}
local button = widget.newButton
{
defaultFile = “button.png”,
overFile = “buttonOver.png”,
width = 500,
height = 190,
font = “Helvetica”,
fontSize = 28,
onEvent = moveEvent
}
button.x = 50; button.y = 50;
scroll:insert(button);
[/lua]