Tableview isCategory row - tap event passing through it to row below

I’ve got a tableView with tappable rows that open external urls (youtube videos)
The first row has isCategory parameter == true.
So it sticks to the top (as it should.)
And the following rows then slide up underneath it (as they should.)
Great so far…

The problem is that if I tap the Category row, the row directly behind it receives the tap and opens its url.
Not good :frowning:

Can anyone suggest how to get around this? Is it a bug?

Thanks people!

My onRowTouch code is below:
p.s. how do you enter code into forums so that it displays nicely like in the corona proj manage IDE.
is it just a print screen?

–================================================
– onEvent listener for the tableView
local function onRowTouch( event )
local row = event.target
local rowGroup = event.view

if event.phase == “press” then
if not row.isCategory then rowGroup.alpha = 0.5; end

elseif event.phase == “tap” then
if not row.isCategory then
row.reRender = true
system.openURL( rowInfo[event.index].theURL)
end

elseif event.phase == “release” then
if not row.isCategory then
row.reRender = true
end
end

return true
end [import]uid: 194387 topic_id: 35197 reply_id: 335197[/import]

  1. Use < code > < / code > (without the spaces) when posting code to the forum. :slight_smile:

  2. Not really sure why you’re using touch and tap listeners in one function but generally speaking return true for tap doesn’t work versus touch and vice versa. So with this hybrid approach you might have to addEventListener() to the same function for both touch and tap, or seperate it out?

[import]uid: 41884 topic_id: 35197 reply_id: 139930[/import]

@richard9 -

  1. thanks for the tip
  2. the tap phase is in the onRowTouch event simply because that’s how they have it in the sample code for Corona tableView tutorial.

I just can’t seem to prevent, at least on the simulator anyway, the ‘TAP’ from propagating past the Category row to the normal row behind it. Is anyone having the same issue? Im using trial build 2012.971 (the latest one)

[import]uid: 194387 topic_id: 35197 reply_id: 140065[/import]

Sorry, my week has been a real mess. This is the first time I’ve had a chance to sit and look at this again. Originally I thought you meant the touch was going through to the background.

Using the exact code below, I couldn’t replicate your problem. It’s possible a fix was made since .971, but you’d have to check the change logs to be sure. Maybe somebody at Corona remembers offhand?

The only advice I can give is to add print statements and check for those rather then checking for code actions; sometimes that’s the best way to tell what is actually a bug versus simply conflicting code.

[code]local widget = require(“widget”)
local list = widget.newTableView{ top = display.statusBarHeight }

local function onRowTouch(event)
local row = event.target; local rowGroup = event.view

if event.phase == “press” then
if not row.isCategory then rowGroup.alpha = 0.5 end

elseif event.phase == “tap” then
if not row.isCategory then row.reRender = true; print(“tap!”) end

elseif event.phase == “release” then
if not row.isCategory then row.reRender = true; print(“press!”) end
end

return true
end

local function onRowRender(event)
local row = event.target
local rowGroup = event.view
local text = display.newText( “Row #”…event.index, 12, 0, “HelveticaNeue-Bold”, 18)
text:setReferencePoint(display.CenterLeftReferencePoint)
text.y = row.height * 0.5
if not row.isCategory then
text.x = 15
text:setTextColor(0)
end
rowGroup:insert(text)
end

for i = 1, 100 do
local rowHeight, rowColor, lineColor, isCategory

if i == 1 or i == 10 then
isCategory = true; rowHeight = 24; rowColor = {70,70,130,255}; lineColor = {0,0,0,255}
end

list:insertRow{
onEvent = onRowTouch,
onRender = onRowRender,
height = rowHeight,
isCategory = isCategory,
rowColor = rowColor,
lineColor = lineColor
}
end[/code] [import]uid: 41884 topic_id: 35197 reply_id: 140330[/import]

  1. Use < code > < / code > (without the spaces) when posting code to the forum. :slight_smile:

  2. Not really sure why you’re using touch and tap listeners in one function but generally speaking return true for tap doesn’t work versus touch and vice versa. So with this hybrid approach you might have to addEventListener() to the same function for both touch and tap, or seperate it out?

[import]uid: 41884 topic_id: 35197 reply_id: 139930[/import]

@richard9 -

  1. thanks for the tip
  2. the tap phase is in the onRowTouch event simply because that’s how they have it in the sample code for Corona tableView tutorial.

I just can’t seem to prevent, at least on the simulator anyway, the ‘TAP’ from propagating past the Category row to the normal row behind it. Is anyone having the same issue? Im using trial build 2012.971 (the latest one)

[import]uid: 194387 topic_id: 35197 reply_id: 140065[/import]

Sorry, my week has been a real mess. This is the first time I’ve had a chance to sit and look at this again. Originally I thought you meant the touch was going through to the background.

Using the exact code below, I couldn’t replicate your problem. It’s possible a fix was made since .971, but you’d have to check the change logs to be sure. Maybe somebody at Corona remembers offhand?

The only advice I can give is to add print statements and check for those rather then checking for code actions; sometimes that’s the best way to tell what is actually a bug versus simply conflicting code.

[code]local widget = require(“widget”)
local list = widget.newTableView{ top = display.statusBarHeight }

local function onRowTouch(event)
local row = event.target; local rowGroup = event.view

if event.phase == “press” then
if not row.isCategory then rowGroup.alpha = 0.5 end

elseif event.phase == “tap” then
if not row.isCategory then row.reRender = true; print(“tap!”) end

elseif event.phase == “release” then
if not row.isCategory then row.reRender = true; print(“press!”) end
end

return true
end

local function onRowRender(event)
local row = event.target
local rowGroup = event.view
local text = display.newText( “Row #”…event.index, 12, 0, “HelveticaNeue-Bold”, 18)
text:setReferencePoint(display.CenterLeftReferencePoint)
text.y = row.height * 0.5
if not row.isCategory then
text.x = 15
text:setTextColor(0)
end
rowGroup:insert(text)
end

for i = 1, 100 do
local rowHeight, rowColor, lineColor, isCategory

if i == 1 or i == 10 then
isCategory = true; rowHeight = 24; rowColor = {70,70,130,255}; lineColor = {0,0,0,255}
end

list:insertRow{
onEvent = onRowTouch,
onRender = onRowRender,
height = rowHeight,
isCategory = isCategory,
rowColor = rowColor,
lineColor = lineColor
}
end[/code] [import]uid: 41884 topic_id: 35197 reply_id: 140330[/import]