Hello,
I am using a tableview with widget 2.0. Works great, but one thing I must be doing wrong.
Here is what I want:
if touch - do task A
if swipe right - do task B
etc.
Problem, when the cell is swiped right, I get a release event, a touch event and a swipe right event. Therefore, I get the correct swipe right task B, but I get task A also. Each event is fired independantly, the onRowTouch is called three times for swipe right, press and release.
Any way I can kill the event on swipe right so the other call (release) is not called?
Thanks!
Daniel
local function tableViewListener( event ) print ("in tableviewlistener") print( event.direction ) print( event.isLimitReached ) end local function onRowUpdate( event ) local phase = event.phase local row = event.row print( row.index, ": is now onscreen" ) end -- onEvent listener for the tableView local function onRowTouch( event ) local phase = event.phase local row = event.target print ("onRowTouch,phase is: "..phase) if event.phase == "press" then print ("event.phase is press") elseif event.phase == "swipeLeft" then print( "Swiped left." ) elseif event.phase == "swipeRight" then print( "Swiped right" ) indexToAdd = event.row.index -- index changes in confirmDeleteFromDatabase local confirmAddToDatabaseAlert = native.showAlert( "Add.."..sponsors[event.row.index].Band, "to 'My Festival'?", { "OK", "Cancel" }, confirmAddToDatabase ) elseif event.phase == "release" then print( "release: You touched row #" .. event.row.index) if (rowCount ~= 0) then print ("rowcount is not zero") groupedStuff.setArtistName(sponsors[event.row.index].Band) --sponsors[event.index].band groupedStuff.setReEntryScreen("ScheduleByTimeDetailScreen") director:changeScene ("ArtistsDetailScreen","moveFromRight") end end return true end -- end fcn onRowTouch -- omit onRowRender for clarity local list = widget.newTableView{ top = 84 + 20 + 44, -- pix plus status bar plus nav bar left = -1, width = 320, height = tableViewHeight, onRowRender = onRowRender, onRowUpdate = onRowUpdate, onRowTouch = onRowTouch, hideBackground = true, maskFile = maskFileName, }
Here is the terminal output for ONE swipe right:
2013-04-14 12:52:15.382 Corona Simulator[55104:707] onRowTouch,phase is: press
2013-04-14 12:52:15.383 Corona Simulator[55104:707] event.phase is press
2013-04-14 12:52:15.538 Corona Simulator[55104:707] onRowTouch,phase is: swipeRight
2013-04-14 12:52:15.538 Corona Simulator[55104:707] Swiped right
2013-04-14 12:52:15.814 Corona Simulator[55104:707] onRowTouch,phase is: release
2013-04-14 12:52:15.814 Corona Simulator[55104:707] You touched row #1
2013-04-14 12:52:15.815 Corona Simulator[55104:707] rowcount is not zero