Deactivate all buttons in overlay screen

Hi.

i am trying to make an overlay screen menu, like a pop up screen, which is smaller as a menu.

The thing is, when the pop up is out, you can still click buttons that are visible in area behind it.

And, it still works. Any idea how to actually make them ‘deactivate’ ?

i have done this,

--creating submenu button --button.createSubMenuButton(group, 367, 275, 243, 240, {world = worlds, wName = worlds, number = num}) button.createSubMenuButton(group, 662, 275, 243, 240, {world = worlds, wName = worlds, number = num}) button.createSubMenuButton(group, 215, 567, 243, 240, {world = worlds, wName = worlds, number = num}) button.createSubMenuButton(group, 513, 567, 243, 240, {world = worlds, wName = worlds, number = num}) button.createSubMenuButton(group, 809, 567, 243, 240, {world = worlds, wName = worlds, number = num}) local subMenu = display.newRect(group, 367, 274, 243, 240) subMenu.alpha = 0.5 --create function for picking pieces number function pickPieces() --create shadow background local shadow = display.newRect(group, wh, hh, 1024, 768) shadow:setFillColor(173/255, 173/255, 173/255) shadow.alpha = 0 --deactivate background shadow.isHitTestable = false --create pieces menu background local pMenu = display.newImage(group, '0141MULTI-Wimmel\_Puzzle/1-Design/2-Final/02\_submenu/ipad/pop\_up\_ipad.jpg', wh, hh) pMenu.alpha=0 --create pieces menu button --create back button for pieces menu local back = display.newCircle(group, 825, 200, 60) back.alpha = 0.5 back:addEventListener("touch", function() dir.changeScene('subMenu1', {world = worlds}) end) --create transition transition.to( shadow, { time=500, alpha=0.5, transition=easing.linear } ) transition.to( pMenu, { time=500, alpha=1, transition=easing.linear } ) end --crate listener subMenu:addEventListener("touch", pickPieces)

if you are using the ‘overlay’ method, you can set ‘isModal’ so that the items behind it are not ‘touchable’.

If you are not using the ‘overlay’ method, then it would be best to ‘removeEventListener’ manually for each button. I would put all the buttons in a table, so that i can easily access them from that table.

–deactivate background
shadow.isHitTestable = false

This is what you need to change.

Leave it hit testable, make sure it covers the whole screen and add a touch listener to it. In the touch listener just add this line: return true

This will prevent touches from passing through it. Any buttons you insert after the shadow will receive touches as normal as they are put on top of the shadow.

thank you for the response. yes, it is actually what I’ve tried, and worked great. the function look like these, for those who want to know the answer.

--create function for picking pieces number function pickPieces() --create shadow background local shadow = display.newRect(group, wh, hh, 1024, 768) shadow:setFillColor(173/255, 173/255, 173/255) shadow.alpha = 0 --deactivate background function coverPressed() return true; end shadow:addEventListener("tap",coverPressed) --create pieces menu background local pMenu = display.newImage(group, '0141MULTI-Wimmel\_Puzzle/1-Design/2-Final/02\_submenu/ipad/pop\_up\_ipad.jpg', wh, hh) pMenu.alpha=0 --create pieces menu button --create back button for pieces menu local back = display.newCircle(group, 825, 200, 60) back.alpha = 0.5 back:addEventListener("touch", function() dir.changeScene('subMenu', {worlds = worlds, worldName = worldName}) end) --create transition transition.to( shadow, { time=500, alpha=0.5, transition=easing.linear } ) transition.to( pMenu, { time=500, alpha=1, transition=easing.linear } ) end

I am not using a storyboard API, yosu. and removing the eventListener would be hard because i just need to deactivate it for a while, and not for a long time.

if you are using the ‘overlay’ method, you can set ‘isModal’ so that the items behind it are not ‘touchable’.

If you are not using the ‘overlay’ method, then it would be best to ‘removeEventListener’ manually for each button. I would put all the buttons in a table, so that i can easily access them from that table.

–deactivate background
shadow.isHitTestable = false

This is what you need to change.

Leave it hit testable, make sure it covers the whole screen and add a touch listener to it. In the touch listener just add this line: return true

This will prevent touches from passing through it. Any buttons you insert after the shadow will receive touches as normal as they are put on top of the shadow.

thank you for the response. yes, it is actually what I’ve tried, and worked great. the function look like these, for those who want to know the answer.

--create function for picking pieces number function pickPieces() --create shadow background local shadow = display.newRect(group, wh, hh, 1024, 768) shadow:setFillColor(173/255, 173/255, 173/255) shadow.alpha = 0 --deactivate background function coverPressed() return true; end shadow:addEventListener("tap",coverPressed) --create pieces menu background local pMenu = display.newImage(group, '0141MULTI-Wimmel\_Puzzle/1-Design/2-Final/02\_submenu/ipad/pop\_up\_ipad.jpg', wh, hh) pMenu.alpha=0 --create pieces menu button --create back button for pieces menu local back = display.newCircle(group, 825, 200, 60) back.alpha = 0.5 back:addEventListener("touch", function() dir.changeScene('subMenu', {worlds = worlds, worldName = worldName}) end) --create transition transition.to( shadow, { time=500, alpha=0.5, transition=easing.linear } ) transition.to( pMenu, { time=500, alpha=1, transition=easing.linear } ) end

I am not using a storyboard API, yosu. and removing the eventListener would be hard because i just need to deactivate it for a while, and not for a long time.