how to disable all events ?

Hi all,

is there a way to disable all events and then enable them. In my app, when user clicks a button a box with information will occur over a tableview. I don’t want the user to be able to tap on tableview while the box is over it. I want him to be able to tap tableview only if he closed that box.

Regards

Abdul

On an individual level, put a boolean in the button code to disable it.

On the global level, put a rectangle with alpha = 0.01 on top of the display, trap tap events and don’t pass them through.

If you are using Storyboard or Composer, you could use an overlay scene for this.  But if not, simply make a rectangle the full size of the screen, make it the background of your box.  You can set it to .isVisible = false and (this is important) .isHitTestable = true then add both a touch and a tap handler to it that basically ignores the events.

local function ignoreTouchs()

     return true

end

local background = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight)

background.isVisible = false

background.isHitTestable = true

background:addEventListener(“touch”, ignoreTouches)

background:addEventListener(“tap”, ignoreTouches)

or something like that.

thanks all , i will give it try and come back to you with results :slight_smile:

Thanks , I didn’t know about isHitTestable, I’ve been putting a near-zero alpha on top :slight_smile:

thanks Rob, 

i tried your way and works perfectly , i appreciate you help :slight_smile:

thanks Paul as well for you help.

Regards

Abdul

On an individual level, put a boolean in the button code to disable it.

On the global level, put a rectangle with alpha = 0.01 on top of the display, trap tap events and don’t pass them through.

If you are using Storyboard or Composer, you could use an overlay scene for this.  But if not, simply make a rectangle the full size of the screen, make it the background of your box.  You can set it to .isVisible = false and (this is important) .isHitTestable = true then add both a touch and a tap handler to it that basically ignores the events.

local function ignoreTouchs()

     return true

end

local background = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight)

background.isVisible = false

background.isHitTestable = true

background:addEventListener(“touch”, ignoreTouches)

background:addEventListener(“tap”, ignoreTouches)

or something like that.

thanks all , i will give it try and come back to you with results :slight_smile:

Thanks , I didn’t know about isHitTestable, I’ve been putting a near-zero alpha on top :slight_smile:

thanks Rob, 

i tried your way and works perfectly , i appreciate you help :slight_smile:

thanks Paul as well for you help.

Regards

Abdul