I have this code:
local btn local function handleBtn( event ) print( "Button Pressed" ) end local function handleTouch( event ) if (event.phase == "began") then print( "Screen Touched" ) end -- Inside Scene Create Function: local options = { shape = "roundedRect", width = 200, height = 100, label = "Button", fontSize = 40, fillColor = { default={1,0,0}, over={1,1,1,0.3}}, onPress = handleBtn } btn = widget.newButton( options ) btn:setEnabled( false ) Runtime:addEventListener( "touch", handleTouch )
This code works fine, the button starts disabled and the screen touch event runs fine. Now when I start the button enabled and disable it later like this:
local function handleBtn( event ) print( "Button Pressed" ) btn:setEnabled( false ) end
Some weird behavior happens:
1- The (handleBtn) function gets called fine, the button gets disabled, but the “over” fill color stays and never goes back to its original color.
2- The touch screen event (handleTouch) no longer gets registered.
Is this a bug, or am I doing something wrong here?
PS: There is nothing else in the scene