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
Or set up a transparent layer on top over everything that also responds to touch, but does not return true (so the touch bleeds through). Then detect if this layer AND the button were touched, and do what you need to do when the transparent layer touch is ended.
Well, in fact it was a false problem because widget buttons send the “cancelled” event, it was just not specified in the doc which say only : “began”, “moved”, or “ended”
Or set up a transparent layer on top over everything that also responds to touch, but does not return true (so the touch bleeds through). Then detect if this layer AND the button were touched, and do what you need to do when the transparent layer touch is ended.
Well, in fact it was a false problem because widget buttons send the “cancelled” event, it was just not specified in the doc which say only : “began”, “moved”, or “ended”