listener bug? why does a 2nd listener pick up this event in this code?

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  

You can try:

Storyboard.showOverlay(“overlay1”, {isModal = true})

this doesn’t help - still has the same issue (had this my app but forgot to put it in the test case).  

So updated the test code in this section to be:

            if event.phase == "ended" then                 print("Show Overlay")                 local options = {isModal = true}                 Storyboard.showOverlay("overlay1", options)             end  

You are likely getting a “tap” event through and I don’t now that isModal catches taps.  I would also add tap handlers in your overlay where you have your touch catchers.

Ok Rob.

So is a tap event different to another touch event? I guess within the table view the “tap” is just one possible phase of the rowTouched event, which as other phases such as “release”.

Plus why wouldn’t the rectangle I put in the overlay trap/stop the tap? Assume tap is just a phase…

Actually after a closer inspection of your code, you are using the onEvent handler.  This is a two phase event  handler just like touch events.  It has a “began” and an “ended” phase.  Your close your overlay on the began phase and the result is your finger is still on the screen, touching your tableView and when you let up, an ended event fires to the tableView.

Why don’t you put an:

if event.phase == “ended”

inside your touch handler for the overlay.

ok thanks Rob got it 

Actually spoke too soon Rob. Adding this check doesn’t help (although I would have thought it would have).

If you move the table view up/down a bit, then click on the button to go to the overlay.  Then click on the overlay button, you still get:

2013-08-27 14:29:09.164 Corona Simulator[14974:707] Hide Overlay 2013-08-27 14:29:09.165 Corona Simulator[14974:707] scene1 - tapped

Even though in the overlay code it reads like:

    -- Button to Go Back     noButton = widget.newButton     {         left=100,         top=150,         id="no",         label="Hide Overlay",         onEvent = function(event)             if event.phase == "ended" then -- Has check in place here                 print("Hide Overlay")                 Storyboard.hideOverlay()             end             return true                                -- Return "true" here         end,     }     scene.view:insert(noButton)  

Have attached the test project (3 files) here:  http://www.qfpost.com/file/d?g=xMyuG4RWp  

Hi Rob - did you have a chance to try this? Make sure you move the table view up and down a bit first (weird I know).

Keen to progress in terms of the fact if I have to take the tap check off my table view is more awkward for the user to click a row, as if they do a quick touch on a row it’s gets interpreted as a tap, and if I don’t check for this it gets ignored

Please file a bug report using the “Report a bug” link above.  This is a very odd behavior and I don’t see why its happening.  Time to put it in the bug tracker.

Thanks

Rob

Case 25818

You can try:

Storyboard.showOverlay(“overlay1”, {isModal = true})

this doesn’t help - still has the same issue (had this my app but forgot to put it in the test case).  

So updated the test code in this section to be:

            if event.phase == "ended" then                 print("Show Overlay")                 local options = {isModal = true}                 Storyboard.showOverlay("overlay1", options)             end  

You are likely getting a “tap” event through and I don’t now that isModal catches taps.  I would also add tap handlers in your overlay where you have your touch catchers.

Ok Rob.

So is a tap event different to another touch event? I guess within the table view the “tap” is just one possible phase of the rowTouched event, which as other phases such as “release”.

Plus why wouldn’t the rectangle I put in the overlay trap/stop the tap? Assume tap is just a phase…

Actually after a closer inspection of your code, you are using the onEvent handler.  This is a two phase event  handler just like touch events.  It has a “began” and an “ended” phase.  Your close your overlay on the began phase and the result is your finger is still on the screen, touching your tableView and when you let up, an ended event fires to the tableView.

Why don’t you put an:

if event.phase == “ended”

inside your touch handler for the overlay.

ok thanks Rob got it 

Actually spoke too soon Rob. Adding this check doesn’t help (although I would have thought it would have).

If you move the table view up/down a bit, then click on the button to go to the overlay.  Then click on the overlay button, you still get:

2013-08-27 14:29:09.164 Corona Simulator[14974:707] Hide Overlay 2013-08-27 14:29:09.165 Corona Simulator[14974:707] scene1 - tapped

Even though in the overlay code it reads like:

    -- Button to Go Back     noButton = widget.newButton     {         left=100,         top=150,         id="no",         label="Hide Overlay",         onEvent = function(event)             if event.phase == "ended" then -- Has check in place here                 print("Hide Overlay")                 Storyboard.hideOverlay()             end             return true                                -- Return "true" here         end,     }     scene.view:insert(noButton)  

Have attached the test project (3 files) here:  http://www.qfpost.com/file/d?g=xMyuG4RWp  

Hi Rob - did you have a chance to try this? Make sure you move the table view up and down a bit first (weird I know).

Keen to progress in terms of the fact if I have to take the tap check off my table view is more awkward for the user to click a row, as if they do a quick touch on a row it’s gets interpreted as a tap, and if I don’t check for this it gets ignored

Please file a bug report using the “Report a bug” link above.  This is a very odd behavior and I don’t see why its happening.  Time to put it in the bug tracker.

Thanks

Rob