Remove all touch events

4 replies [Last post]
MichaelAssadi
User offline. Last seen 2 days 13 hours ago. Offline
Joined: 20 Jan 2011

Hello,

I have a quick question. Do yo you know if it's possible to remove all touch events on the screen when pressed a button? Without individually removing them? Is their any one code stopping you from touching anything?

Thanks.

- Michael

Replies

peach pellen's picture
peach pellen
User offline. Last seen 1 day 13 hours ago. Offline
Staff
Joined: 12 Apr 2011

There isn't a single line of code to remove all touch listeners, you'd manually remove each one using obj:removeEventListener().

That said, why are you removing them? If it is to prevent users clicking them while you have something going on you could use set focus OR you could put a transparent rectangle over your screen that is hitTestable and put a function on it that simply returns true on touch.

Peach :)

MichaelAssadi
User offline. Last seen 2 days 13 hours ago. Offline
Joined: 20 Jan 2011

Yes that is correct.

Thanks :)

So If i return true the touch events will deactivate?

- Michael

Danny's picture
Danny
User offline. Last seen 1 hour 24 min ago. Offline
Staff
Joined: 17 Aug 2011

They wont de-activate. it will just stop touch events leaking to objects below them and also prevents over use of a touch event (without return true, your function could be called x number of times per touch rather than the expected behavior)

MichaelAssadi
User offline. Last seen 2 days 13 hours ago. Offline
Joined: 20 Jan 2011

Ok, thanks guys!

That's exactly what i need to know! :)

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.