Is there a way I can make a button disable user input? The use must then push another button/the same button to re-enable input
Cheers
Is there a way I can make a button disable user input? The use must then push another button/the same button to re-enable input
Cheers
Hi, this might help :
local button = display.newRect(160,100,60,30) local enabled = "true" function enable() if (e.phase == "began") then if enabled == "true" then enabled = "false" -- disable the input else enabled = "true" -- enable input end end end button:addEventListener("touch", enable)
So does this make a single button disable and enable user input? How would I implement it into this code, cheers
local widget = require( "widget" ) -- Function to handle button events local function handleButtonEvent( event ) if event.phase == "ended" and eggplant.alpha ~= 1 then eggplant.alpha = 1 physics.addBody(eggplant, "dynamic", {radius = 20, friction = .4, density = 0.00001, bounce = 0}) eggplant.x = 40 eggplant.y = 0 eggplant.rotation = 0 end if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end local addeggplant = widget.newButton( { width = 58, height = 70, defaultFile = "shapes/pipebutton.png", overFile = "shapes/pipebutton.png", label = "", onEvent = handleButtonEvent } ) -- Center the button addeggplant.x = 40 addeggplant.y = 5 -- Change the button's label text addeggplant:setLabel( "" ) sceneGroup:insert(addeggplant)
Hi, this might help :
local button = display.newRect(160,100,60,30) local enabled = "true" function enable() if (e.phase == "began") then if enabled == "true" then enabled = "false" -- disable the input else enabled = "true" -- enable input end end end button:addEventListener("touch", enable)
So does this make a single button disable and enable user input? How would I implement it into this code, cheers
local widget = require( "widget" ) -- Function to handle button events local function handleButtonEvent( event ) if event.phase == "ended" and eggplant.alpha ~= 1 then eggplant.alpha = 1 physics.addBody(eggplant, "dynamic", {radius = 20, friction = .4, density = 0.00001, bounce = 0}) eggplant.x = 40 eggplant.y = 0 eggplant.rotation = 0 end if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end local addeggplant = widget.newButton( { width = 58, height = 70, defaultFile = "shapes/pipebutton.png", overFile = "shapes/pipebutton.png", label = "", onEvent = handleButtonEvent } ) -- Center the button addeggplant.x = 40 addeggplant.y = 5 -- Change the button's label text addeggplant:setLabel( "" ) sceneGroup:insert(addeggplant)