cancel all the event with one command

please add a feature using which we can use to disable all the events of one event type with one command
like disable all touch events and enable all disable touch event.
regards
syed usama
[import]uid: 34898 topic_id: 13307 reply_id: 313307[/import]

I guess that would be os.exit()
well, I am not sure if there is a way to do that unless you have a single listener and set a flag to ignore that event.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 13307 reply_id: 48948[/import]

are u looking for something like this,

[lua]local rect = display.newRect(0,0,100,100)
local rect1 = display.newRect(0,120,100,100)
local rect2 = display.newRect(0,240,100,100)
local function touchEvent(e)
print(“events fired”)
end
rect:addEventListener(“touch”,touchEvent)
rect1:addEventListener(“touch”,touchEvent)
rect2:addEventListener(“touch”,touchEvent)

local pauseRect
local function pauseAllEvent(e)
print(“no event will fire”)

return true
end
local function disableAllEvents()
pauseRect = display.newRect(0,0,display.contentWidth,display.contentHeight)
pauseRect:setFillColor(100,0,0,100)
pauseRect:addEventListener(“touch”,pauseAllEvent)
end
timer.performWithDelay(5000,disableAllEvents)[/lua]

you can see no event will fire after 5 seconds and if later id you remove pauseRect you will get all events again [import]uid: 12482 topic_id: 13307 reply_id: 48964[/import]

no i want to that i can disable all the events and then call new event like
event.disable(“touch”,all)

rect:addEvent(“touch”,abc)
and when ever i want
i can call

event.enable(“touch”,all)

something like that or stop one event to propagate …
[import]uid: 34898 topic_id: 13307 reply_id: 49044[/import]

well for that you can use one flag say something like

local myFlag = true

and in all the listener you have to chk for it’s value

function ff1()
if myFlag == true then

end

end

function ff1()
if myFlag == false then

end

end

in this way you can toggle listeners
:slight_smile:
[import]uid: 12482 topic_id: 13307 reply_id: 49149[/import]