Hello,
I need button that work “on the fly”. I mean if I stay pushed on a button, I get all the events.
The following code stop working good when I stay clicked on the button then I release it outside of the button…
local widget=require(“widget”)
local wbutton
local function onEventButton(evt)
if evt.phase==“began” then
display.getCurrentStage():setFocus(evt.target)
wbutton.isFocus=true
elseif evt.phase==“ended” then
display.getCurrentStage():setFocus(nil)
wbutton.isFocus=false
end
return true
end
wbutton=widget.newButton({onEvent=onEventButton})
wbutton.isFocus=false
local function onEnterframe(evt)
if wbutton.isFocus then print(“OK”) else print(“ko”) end
end
Runtime:addEventListener(“enterFrame”,onEnterframe)