Is there a bug here? Or what am I doing wrong. In the following code if you:
a) run the code
b) scroll the table view rows up again
c) click on the “push me” button
d) click quickly on the “hide overlay” button, then you get
2013-08-26 21:21:00.650 Corona Simulator[9307:707] Hide Overlay
2013-08-26 21:21:00.770 Corona Simulator[9307:707] scene1 - tapped
Why is the “onRowTouch” firing and printing out the “scene1 - tapped”? That is, in the overlay scene the event does get trapped and then return a “true”, so does that not imply it should NOT be picked up by another event handler again?
onEvent = function(event) print("Hide Overlay") Storyboard.hideOverlay() return true -- Return "true" here end,
display.setStatusBar( display.HiddenStatusBar ) \_G.Storyboard = require("storyboard") Storyboard.gotoScene( "scene1") -- ========================== -- scene1.lua local widget = require( "widget" ) local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function scene:createScene( event ) -- Forward reference for our tableView local tableView = nil -- Handle touches on the row local function onRowTouch( event ) if event.phase == "tap" then -- LOOKING FOR A TAP print("scene1 - tapped") end end -- Create a tableView tableView = widget.newTableView { top = 32, width = 320, height = 400, listener = tableViewListener, onRowTouch = onRowTouch, } self.view:insert( tableView ) -- Create 100 rows for i = 1, 100 do local isCategory = false local rowHeight = 40 local rowColor = { default = { 255, 255, 255 }, over = { 30, 144, 255 }, } local lineColor = { 220, 220, 220 } -- Make some rows categories if i == 25 or i == 50 or i == 75 then isCategory = true rowHeight = 24 rowColor = { default = { 200,0,0, 200 }, } end -- Insert the row into the tableView tableView:insertRow { isCategory = isCategory, rowHeight = rowHeight, rowColor = rowColor, lineColor = lineColor, } end -- Button to trigger showing Overlay local unlockButton = widget.newButton { left = 100, top = 100, width = 100, height = 50, label="push me", onEvent = function (event) if event.phase == "ended" then print("Show Overlay") Storyboard.showOverlay("overlay1") end return true -- Return "true" here end } scene.view:insert(unlockButton) end scene:addEventListener( "createScene" ) return scene -- ========================================= -- overlay1.lua local scene = Storyboard.newScene() -- i.e. a Non SceneBase.lua scene - Don't want Menu/Inventory local widget = require "widget" local workAroundRect -- Listeners local function blockBackgroundTouches(event) return true end -- Scene Handlers function scene:createScene( event ) -- Block Background workAroundRect = display.newRect(scene.view, 0, 0, display.contentWidth, display.contentHeight) workAroundRect.strokeWidth = 0 workAroundRect:setFillColor(140, 140, 140, 200) -- Button to Go Back noButton = widget.newButton { left=100, top=150, id="no", label="Hide Overlay", onEvent = function(event) print("Hide Overlay") Storyboard.hideOverlay() return true -- Return "true" here end, } scene.view:insert(noButton) end function scene:enterScene( event ) workAroundRect:addEventListener("touch", blockBackgroundTouches) end function scene:exitScene( event ) workAroundRect:removeEventListener("touch", blockBackgroundTouches) end function scene:destroyScene( event ) end -- Scene Listeners scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene