I have a table view that has a button (and some other stuff) on each row.
When the user taps a button in one of the rows, I want to do one thing; when they tap a row outside the button, I want to do another thing.
The problem is that when I tap a button on a row, both event listeners fire - the button listener first, and the row listener second.
I want the button listener (only) to fire when the button is tapped, and the row listener (only) to fire when the row is tapped outside of the button on that row.
local function btnRowListener (event)
print (“exiting btnRowListener”)
return true
end
local function rowRender (event)
local row = event.row
local rowHeight = row.height
local rowWidth = row.width
local btnRow = widget.newSwitch {
x = 10, y = row.height / 2,
style = “checkbox”,
onPress = btnRowListener
}
row:insert(btnRow)
local options_name = {parent = row, text = row.params.name, x = 40, y = row.height / 2, font = native.systemFont, fontSize = 14}
row.name = display.newText(options_name)
end
local function rowTouchListener (event)
local row = event.row
print ("exiting rowTouchListener ")
end
tv = widget.newTableView
{
x = dsp.centerX, y = dsp.centerY + (dsp.navBarHeight / 2),
width = dsp.width, height = dsp.height - dsp.navBarHeight,
onRowRender = rowRender,
onRowTouch = rowTouchListener
}