Overlay Ismodal Still Broken?

briforge, you have these two lines here:

[lua]

oFix:addEventListener( “tap”, catchStrays )

oFix:addEventListener( “touch”, catchStrays )

[/lua]

…but in the code shown you don’t have a function called catchStrays.

Do this outside of the createScene function:

[lua]

local function catchStrays(event)

   return true

end

[/lua]

That should fix the problem.

Jay

Jay,

Thanks for your response.  I actually did have that catchStrays(event) method, exactly as you had it, and outside of the createScene function. I just forgot to include it in my code snippet.  It still doesn’t work, the taps still get propagated down to the underlying scene.

You might need to put the catchStrays function above the createScene function,  just after the onOkBtnRelease function.  Or, alternatively, forward declare catchStrays next to where you declare local okBtn.

I do have the catchStrays function above the createScene function.  It’s not being called.  I put a print statement in there.  So something else fishy is going on.  This is yet another case where a modern IDE and/or debugger might help.

@briforge: Is the problem that you have both a “tap” and a “touch” event listener on the same object? I haven’t used “tap”, so I don’t know if you can have both. Maybe try commenting out one line and seeing if your print statement executes.

After more testing, I’ve discovered it has something to do with the button.  If I tap anywhere else on the overlay, the taps and touches are caught as expected in the catchStrays.  But when I tap on the button, the button event handler is called and then the tap event continues down to the underlying scene.

I’ve tried delaying the storyboard.hideOverlay in the button handler, but that didn’t work either.

Are you doing a:

return true

in your button’s event handler?

Yes. It’s in the original code post I did above, in the onOkBtnRelease() function.

I wanted to add another ‘Me too’ to this issue, and also ask for further help on the workaround.  The overlay I’m using is a simple tutorial popup with text and an ‘OK’ button.  The button is a widget.newButton.  The function that is called onRelease for the button is returning true.  I’ve also tried the rectangle behind the whole overlay to try to catch taps and touches, but that’s not working either. Here’s the relevant code from the overlay : 

-- forward declarations and other locals local okBtn -- 'onRelease' event listener for okBtn local function onOkBtnRelease() storyboard.hideOverlay() return true -- indicates successful touch end function scene:createScene( event ) local group = self.view -- overlay fix; to prevent taps from going thru to underlying screen local oFix = display.newRect( group, 0, 0, screenWidth, screenHeight ) oFix:setFillColor(0,0,0) oFix.alpha = .7 oFix:addEventListener( "tap", catchStrays ) oFix:addEventListener( "touch", catchStrays ) local myRoundedRect = display.newRoundedRect(10, 10, 250, 250, 12) myRoundedRect.strokeWidth = 3 myRoundedRect:setStrokeColor(180, 180, 180) group:insert(myRoundedRect) local wrappedText = display.newText( event.params.msg, 25, 25, 200, 200, native.systemFont, 18 ) wrappedText:setTextColor(0,0,0) group:insert( wrappedText ) -- create a widget button okBtn = widget.newButton{ label="OK", labelColor = { default={255}, over={128} }, defaultFile="button.png", overFile="button-over.png", width=154, height=40, onRelease = onOkBtnRelease -- event listener function } okBtn:setReferencePoint( display.TopLeftReferencePoint ) okBtn.x = 50 okBtn.y = 200 group:insert(okBtn) end

briforge, you have these two lines here:

[lua]

oFix:addEventListener( “tap”, catchStrays )

oFix:addEventListener( “touch”, catchStrays )

[/lua]

…but in the code shown you don’t have a function called catchStrays.

Do this outside of the createScene function:

[lua]

local function catchStrays(event)

   return true

end

[/lua]

That should fix the problem.

Jay

Jay,

Thanks for your response.  I actually did have that catchStrays(event) method, exactly as you had it, and outside of the createScene function. I just forgot to include it in my code snippet.  It still doesn’t work, the taps still get propagated down to the underlying scene.

You might need to put the catchStrays function above the createScene function,  just after the onOkBtnRelease function.  Or, alternatively, forward declare catchStrays next to where you declare local okBtn.

I do have the catchStrays function above the createScene function.  It’s not being called.  I put a print statement in there.  So something else fishy is going on.  This is yet another case where a modern IDE and/or debugger might help.

@briforge: Is the problem that you have both a “tap” and a “touch” event listener on the same object? I haven’t used “tap”, so I don’t know if you can have both. Maybe try commenting out one line and seeing if your print statement executes.

After more testing, I’ve discovered it has something to do with the button.  If I tap anywhere else on the overlay, the taps and touches are caught as expected in the catchStrays.  But when I tap on the button, the button event handler is called and then the tap event continues down to the underlying scene.

I’ve tried delaying the storyboard.hideOverlay in the button handler, but that didn’t work either.

Are you doing a:

return true

in your button’s event handler?

Yes. It’s in the original code post I did above, in the onOkBtnRelease() function.

I had a similar problem, where my touches goes through to the  background, even though isModal = true.

After checking all my event-functions, and ensure they all returned ‘true’, it solves the problem. Now, it does not go through anymore.

I had a similar problem, where my touches goes through to the  background, even though isModal = true.

After checking all my event-functions, and ensure they all returned ‘true’, it solves the problem. Now, it does not go through anymore.