This is the way I do it now to get instant feedback, the onRowTouch function is not used, you can copy paste into main to see it work:
[lua]
display.setStatusBar( display.HiddenStatusBar )
local widget = require( “widget” )
local tableView
– Regular method, not used
local function onRowTouch(event)
if event.phase == ‘tap’ then
native.showAlert("Row " … event.target.index, “Selected”)
end
end
– Table view listener
local startXpos = 0 – Position of finger when you first touch a row
local startYpos = 0
local buffer = 5 – How much you can move your finger around but still be counted as selected
local function tableViewListener(event)
local phase = event.phase
local row = event.target
if phase == “began” and not row.selected then
startXpos = event.x
startYpos = event.y
row.selected = true
elseif phase == “ended” or phase == “moved” then
row.selected = false
if phase == “ended” and event.y < startYpos + buffer and event.y > startYpos - buffer and event.x < startXpos + buffer and event.x > startXpos - buffer then
native.showAlert("Row " … row.index, “Selected”)
end
end
end
local function onRowRender( event )
local row = event.row
local rowTitle = display.newText( row, "SELECT ME " … row.index, 0, 0, nil, 14 )
rowTitle.x = display.contentWidth / 2
rowTitle.y = row.contentHeight * 0.5
rowTitle:setTextColor( 0, 0, 0 )
end
– Create a tableView
tableView = widget.newTableView {
width = display.contentWidth,
height = display.contentHeight,
onRowRender = onRowRender,
– onRowTouch = onRowTouch, – Old
listener = tableViewListener, – New
}
tableView:insertRow{rowHeight = 40}
tableView:insertRow{rowHeight = 40}
tableView:insertRow{rowHeight = 40}
[/lua]