isModal is messing with me and hide overlay too

Hi,
I have the following code

 local options =  
 {  
 isModal=true  
 }  
  
 storyboard.showOverlay( "results", options )  

If I use this the buttons below the pop up screen are still hit testable.
i could change this by changing the overlay began to hittestable = false but that is cumbersome.

How do I use this isModal.

And when the screen pops up, and I call the hideOverlay option, the screen does not go away. The remove pop up text does appear though

This is in my results file

 function rem(event)  
 print("remove pop up")  
 storyboard.hideOverlay("")  
 end  
  
achtergrond=display.newRect(0,0,600,500)  
achtergrond:setFillColor(255,0,0)  
  
test=display.newRect(100,100,100,100)  
test:setFillColor(100,100,100)  
test:addEventListener("touch",rem)  

I guess I am missing something.
Thanks for reading [import]uid: 100901 topic_id: 36058 reply_id: 336058[/import]

Hi Juf,

I’m having the same problem with getting “isModal” to work for me (and it appears I posted within minutes of you on the issue as well!: http://developer.coronalabs.com/forum/2013/02/18/storyboardshowoverlay-ismodal-key-functional-other-solutions-preventing-touches ). No ideas yet but hopefully someone can share some info that’s helpful.

As far as hideOverlay() goes, mine works fine as long as I’m using some parameters. See if something like this works for you:
[lua]
storyboard.hideOverlay( “slideDown” , 1500)
[/lua]

[import]uid: 105707 topic_id: 36058 reply_id: 143238[/import]

I would suggest grabbing a later daily build and see if it fixes it.

There were several storyboard bugs fixed since 971 I think. [import]uid: 199310 topic_id: 36058 reply_id: 143258[/import]

Hi Juf Jannie.

If I understood correctly, your buttons below the popup belongs to the active screen, correct?

After playing around with overlay, I found that the isModal = true only disables the touch of your popup. The touch listener outside your popup (i.e, that are in the active screen that called the overlay scene) will still work.

To disable them, just called removeListener function before calling the overlay.

One trick: If the overlay appears while the user was still touching the screen, I think the removeListener will not work (at least I had that problem with my game here). I solved that problem forcing the touch event before calling the overlay to became .phase = “ended”. So, before I call the overlay, the event is terminated and the removeListener works normally.

Renato
Red Beach Games
Try our new game Puzzle You for free here!
[import]uid: 181011 topic_id: 36058 reply_id: 143274[/import]

I was working on a modal overlay during the weekend and saw a similar issue.
I’m using build 1031, and it kinda works. Most of the time it doesn’t let key touches through, but I have 2 buttons where *part* of the button lets touches through. A small edge on one side of either button registers touches. I’m trying to isolate the problem to see whats going on. [import]uid: 70847 topic_id: 36058 reply_id: 143265[/import]

I’ve have a window that’s 200x190px that I call as a modal overlay. All buttons on the calling storyboard scene become inactive *except* parts of buttons that happen to be in a 0-40px region on the left and right side. Only the part of the button that lies in that region lets touches go through. Oddly enough when I set to simulator to iPad/iPad Retina, it behaves as it should and no touches are let through anywhere.

@Juf
If hideOverlay doesn’t remove the overlay, make sure you’ve added all scene objects to your overlay’s view (like group:insert(object))
Also isHitTestable only modifies the event behavior of hidden objects, so it will not work to disable touches for visible buttons.

I’ve temporarily solved the problem by adding a flag indicating if an overlay is active and handling the touch events myself.

I think that a new version of the widget library is due to be released soon. I’ll get by until then. [import]uid: 70847 topic_id: 36058 reply_id: 143288[/import]

I’ve personally never uses the isModal flag. I tend to drop full screen backgrounds on my overlays, sometimes making them partially transparent and as a habit, I drop a touch handler on the background that absorbs any touch events I don’t want propagating to layers underneath. It kinda makes my own version of a modal window.

I did a sample test:

-- main.lua  
local storyboard = require "storyboard"  
  
storyboard.gotoScene("a")  
-- a.lua  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
  
 local background = display.newRect(0,0,display.contentWidth,display.contentHeight)  
 group:insert(background)  
 background:setFillColor(255,0,0)  
 background.x = display.contentWidth / 2  
 background.y = display.contentHeight / 2  
 -- background:addEventListener("touch", utility.ignoreTouch)  
  
 local closeBtn = display.newRect(0, 0, 128, 48)  
 group:insert(closeBtn)  
 closeBtn.x = display.contentWidth / 2   
 closeBtn.y = display.contentHeight / 2 - 200  
 closeBtn:setFillColor(0,0,255)  
 local function closeForm(event)  
 if event.phase == "began" then  
 closeBtn:setFillColor(0,255,0)  
 elseif event.phase == "ended" then  
 closeBtn:setFillColor(0,0,255)  
 end  
 return true  
 end  
 closeBtn:addEventListener("touch", closeForm)  
  
 local testBtn = display.newRect(0, 0, 128, 48)  
 group:insert(testBtn)  
 testBtn.x = display.contentWidth / 2   
 testBtn.y = display.contentHeight / 2 + 100  
 testBtn:setFillColor(0,0,255)  
 local function testForm(event)  
 if event.phase == "began" then  
 testBtn:setFillColor(0,255,0)  
 elseif event.phase == "ended" then  
 testBtn:setFillColor(0,0,255)  
 end  
 return true  
 end  
 testBtn:addEventListener("touch", testForm)  
end  
  
function scene:enterScene( event )  
 local group = self.view  
 storyboard.showOverlay("b", {isModal = true})  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

and

-- b.lua  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
function scene:createScene( event )  
 local group = self.view  
  
 local background = display.newRect(0,0,200,200)  
 group:insert(background)  
 background.x = display.contentWidth / 2  
 background.y = display.contentHeight / 2  
 background:setFillColor(128,128,128)  
 background.alpha = 0.5  
  
 local closeBtn = display.newRect(0,0, 128, 48)  
 group:insert(closeBtn)  
 closeBtn.x = display.contentWidth / 2   
 closeBtn.y = display.contentHeight / 2  
 local function closeForm(event)  
 if event.phase == "ended" then  
 storyboard.hideOverlay("fade", 500)  
 end  
 return true  
 end  
 closeBtn:addEventListener("touch", closeForm)  
 closeBtn.isVisible = true  
end  
  
function scene:enterScene( event )  
 local group = self.view  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

This sets up a scene with a red background and two blue buttons that turn green when you touch them. I load b.lua as a modal overlay. One of the buttons is outside of the box created by b.lua, one is partially obscured.

Using build 1031, I cannot touch either of the buttons while the overlay is there. When I close the overlay (center white button), then the buttons start behaving correctly.

I also tested it with the latest public build (971) and it also works as expected. [import]uid: 199310 topic_id: 36058 reply_id: 143397[/import]

Hi Rob,

I had originally attempted to “hack” a solution as you suggested by using an event listener on an alpha’d out full screen background on my overlay to prevent touch events propagating. This hadn’t worked for me the first time around but since you mentioned it as an option, I revisited my effort and discovered that my “return true” on the overlay background was only for “began” touch events. I’ve fixed this and the “hack” now works.

I’ve tested your code sample out and the “isModal = true” works correctly on my .971 set up. This is definitely reassuring, but also odd that it doesn’t work in the project I’m working on! I’m not sure why one would work and the other wouldn’t!

Regardless, I have a solution that works. I’m glad for that and can keep moving forward.

Thanks for your help :slight_smile: [import]uid: 105707 topic_id: 36058 reply_id: 143433[/import]

I ended up doing something similar. Background that intercepts the touch.

But it is good to see so much progress in Corona. [import]uid: 100901 topic_id: 36058 reply_id: 143466[/import]

Hi Juf,

I’m having the same problem with getting “isModal” to work for me (and it appears I posted within minutes of you on the issue as well!: http://developer.coronalabs.com/forum/2013/02/18/storyboardshowoverlay-ismodal-key-functional-other-solutions-preventing-touches ). No ideas yet but hopefully someone can share some info that’s helpful.

As far as hideOverlay() goes, mine works fine as long as I’m using some parameters. See if something like this works for you:
[lua]
storyboard.hideOverlay( “slideDown” , 1500)
[/lua]

[import]uid: 105707 topic_id: 36058 reply_id: 143238[/import]

I would suggest grabbing a later daily build and see if it fixes it.

There were several storyboard bugs fixed since 971 I think. [import]uid: 199310 topic_id: 36058 reply_id: 143258[/import]

Hi Juf Jannie.

If I understood correctly, your buttons below the popup belongs to the active screen, correct?

After playing around with overlay, I found that the isModal = true only disables the touch of your popup. The touch listener outside your popup (i.e, that are in the active screen that called the overlay scene) will still work.

To disable them, just called removeListener function before calling the overlay.

One trick: If the overlay appears while the user was still touching the screen, I think the removeListener will not work (at least I had that problem with my game here). I solved that problem forcing the touch event before calling the overlay to became .phase = “ended”. So, before I call the overlay, the event is terminated and the removeListener works normally.

Renato
Red Beach Games
Try our new game Puzzle You for free here!
[import]uid: 181011 topic_id: 36058 reply_id: 143274[/import]

I was working on a modal overlay during the weekend and saw a similar issue.
I’m using build 1031, and it kinda works. Most of the time it doesn’t let key touches through, but I have 2 buttons where *part* of the button lets touches through. A small edge on one side of either button registers touches. I’m trying to isolate the problem to see whats going on. [import]uid: 70847 topic_id: 36058 reply_id: 143265[/import]

I’ve have a window that’s 200x190px that I call as a modal overlay. All buttons on the calling storyboard scene become inactive *except* parts of buttons that happen to be in a 0-40px region on the left and right side. Only the part of the button that lies in that region lets touches go through. Oddly enough when I set to simulator to iPad/iPad Retina, it behaves as it should and no touches are let through anywhere.

@Juf
If hideOverlay doesn’t remove the overlay, make sure you’ve added all scene objects to your overlay’s view (like group:insert(object))
Also isHitTestable only modifies the event behavior of hidden objects, so it will not work to disable touches for visible buttons.

I’ve temporarily solved the problem by adding a flag indicating if an overlay is active and handling the touch events myself.

I think that a new version of the widget library is due to be released soon. I’ll get by until then. [import]uid: 70847 topic_id: 36058 reply_id: 143288[/import]

I’ve personally never uses the isModal flag. I tend to drop full screen backgrounds on my overlays, sometimes making them partially transparent and as a habit, I drop a touch handler on the background that absorbs any touch events I don’t want propagating to layers underneath. It kinda makes my own version of a modal window.

I did a sample test:

-- main.lua  
local storyboard = require "storyboard"  
  
storyboard.gotoScene("a")  
-- a.lua  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
  
 local background = display.newRect(0,0,display.contentWidth,display.contentHeight)  
 group:insert(background)  
 background:setFillColor(255,0,0)  
 background.x = display.contentWidth / 2  
 background.y = display.contentHeight / 2  
 -- background:addEventListener("touch", utility.ignoreTouch)  
  
 local closeBtn = display.newRect(0, 0, 128, 48)  
 group:insert(closeBtn)  
 closeBtn.x = display.contentWidth / 2   
 closeBtn.y = display.contentHeight / 2 - 200  
 closeBtn:setFillColor(0,0,255)  
 local function closeForm(event)  
 if event.phase == "began" then  
 closeBtn:setFillColor(0,255,0)  
 elseif event.phase == "ended" then  
 closeBtn:setFillColor(0,0,255)  
 end  
 return true  
 end  
 closeBtn:addEventListener("touch", closeForm)  
  
 local testBtn = display.newRect(0, 0, 128, 48)  
 group:insert(testBtn)  
 testBtn.x = display.contentWidth / 2   
 testBtn.y = display.contentHeight / 2 + 100  
 testBtn:setFillColor(0,0,255)  
 local function testForm(event)  
 if event.phase == "began" then  
 testBtn:setFillColor(0,255,0)  
 elseif event.phase == "ended" then  
 testBtn:setFillColor(0,0,255)  
 end  
 return true  
 end  
 testBtn:addEventListener("touch", testForm)  
end  
  
function scene:enterScene( event )  
 local group = self.view  
 storyboard.showOverlay("b", {isModal = true})  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

and

-- b.lua  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
function scene:createScene( event )  
 local group = self.view  
  
 local background = display.newRect(0,0,200,200)  
 group:insert(background)  
 background.x = display.contentWidth / 2  
 background.y = display.contentHeight / 2  
 background:setFillColor(128,128,128)  
 background.alpha = 0.5  
  
 local closeBtn = display.newRect(0,0, 128, 48)  
 group:insert(closeBtn)  
 closeBtn.x = display.contentWidth / 2   
 closeBtn.y = display.contentHeight / 2  
 local function closeForm(event)  
 if event.phase == "ended" then  
 storyboard.hideOverlay("fade", 500)  
 end  
 return true  
 end  
 closeBtn:addEventListener("touch", closeForm)  
 closeBtn.isVisible = true  
end  
  
function scene:enterScene( event )  
 local group = self.view  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

This sets up a scene with a red background and two blue buttons that turn green when you touch them. I load b.lua as a modal overlay. One of the buttons is outside of the box created by b.lua, one is partially obscured.

Using build 1031, I cannot touch either of the buttons while the overlay is there. When I close the overlay (center white button), then the buttons start behaving correctly.

I also tested it with the latest public build (971) and it also works as expected. [import]uid: 199310 topic_id: 36058 reply_id: 143397[/import]

Hi Rob,

I had originally attempted to “hack” a solution as you suggested by using an event listener on an alpha’d out full screen background on my overlay to prevent touch events propagating. This hadn’t worked for me the first time around but since you mentioned it as an option, I revisited my effort and discovered that my “return true” on the overlay background was only for “began” touch events. I’ve fixed this and the “hack” now works.

I’ve tested your code sample out and the “isModal = true” works correctly on my .971 set up. This is definitely reassuring, but also odd that it doesn’t work in the project I’m working on! I’m not sure why one would work and the other wouldn’t!

Regardless, I have a solution that works. I’m glad for that and can keep moving forward.

Thanks for your help :slight_smile: [import]uid: 105707 topic_id: 36058 reply_id: 143433[/import]

I ended up doing something similar. Background that intercepts the touch.

But it is good to see so much progress in Corona. [import]uid: 100901 topic_id: 36058 reply_id: 143466[/import]

Hi Juf,

I’m having the same problem with getting “isModal” to work for me (and it appears I posted within minutes of you on the issue as well!: http://developer.coronalabs.com/forum/2013/02/18/storyboardshowoverlay-ismodal-key-functional-other-solutions-preventing-touches ). No ideas yet but hopefully someone can share some info that’s helpful.

As far as hideOverlay() goes, mine works fine as long as I’m using some parameters. See if something like this works for you:
[lua]
storyboard.hideOverlay( “slideDown” , 1500)
[/lua]

[import]uid: 105707 topic_id: 36058 reply_id: 143238[/import]

I would suggest grabbing a later daily build and see if it fixes it.

There were several storyboard bugs fixed since 971 I think. [import]uid: 199310 topic_id: 36058 reply_id: 143258[/import]

Hi Juf Jannie.

If I understood correctly, your buttons below the popup belongs to the active screen, correct?

After playing around with overlay, I found that the isModal = true only disables the touch of your popup. The touch listener outside your popup (i.e, that are in the active screen that called the overlay scene) will still work.

To disable them, just called removeListener function before calling the overlay.

One trick: If the overlay appears while the user was still touching the screen, I think the removeListener will not work (at least I had that problem with my game here). I solved that problem forcing the touch event before calling the overlay to became .phase = “ended”. So, before I call the overlay, the event is terminated and the removeListener works normally.

Renato
Red Beach Games
Try our new game Puzzle You for free here!
[import]uid: 181011 topic_id: 36058 reply_id: 143274[/import]