I want to block all mouse/touch events to my interface while I complete some network communications. It may take a second or two for the comms to complete and I don't want to launch another communication until that last one completes.
I tried an invisible rectangle, but I must be doing something wrong since the bitmap continues to get clicks when i move it offscreen:
blockRect = (Bitmap.new(Texture.new("images/transparentBlock.png")))
self:addChild(blockRect)
blockRect:setX(1500)))
blockRect:addEventListener(Event.MOUSE_DOWN, blockClicks,e)
function blockClicks(e)
print(e.x,e.y,e.target,e.type)
e:stopPropagation()
end |
Why is the blockRect still receiving MOUSE_DOWN events when it isn't on screen?
Comments
Try adding the following extension methods to Sprite:
I thought it might be faster to move the sprite's X value as opposed to creating/destroying it. Does anyone know if that is true?
Since the ignoreTouchHandler() function stops the event propagation for ALL the events it gets, whether or not they are within the shield sprite bounds or not, then it will block all the events from any of the other objects.
If you want to see the effect in action, download that BhPopup class from the link above.
Best regards
So, move the Sprite won't work. The bitmap continues to get click event because all mouse events always received by all Sprite (including it's descentdant e.g. Bitmap) whereever the mouse events occur. In your case, you can filter mouse event position by using Sprite:hitTestPoint