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]