How Do I Get Exclusive Touch Events In Tableview?

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

I would also like to know the answer for this!

I would also like to know the answer for this!

I am working on a similar issue and I found that the order of events for the Table View is: press, swipe[left or right], and release. I have found that it is better to respond to the user’s touch on a Table View during the “release” phase not the “press” phase. That way the user has the opportunity to move off their finger/thumb off the screen while touching in order to cancel the touch. In other words the “release” phase may not fire if the user touches a row and then moves their finger/thumb off the screen while still touching.

But concerning your issue … by acting upon the touch in the release phase you get:

if touch(press) - do nothing

if swipe right - do task B

if release - do task A

etc.

 

If they touch(press) and release then no swipe event is registered and Task A will be triggered. If they touch(press) and swipe then Task B will be triggered.

 

So how do you cancel a specific event? I have not found a way to programmatically cancel an event other than … just do nothing. Also you can set up a flag that detects if Task B was performed then don’t perform Task A (if a release is detected) based on the flag.

 

Let me know how it works for you.

 

Theo

I am working on a similar issue and I found that the order of events for the Table View is: press, swipe[left or right], and release. I have found that it is better to respond to the user’s touch on a Table View during the “release” phase not the “press” phase. That way the user has the opportunity to move off their finger/thumb off the screen while touching in order to cancel the touch. In other words the “release” phase may not fire if the user touches a row and then moves their finger/thumb off the screen while still touching.

But concerning your issue … by acting upon the touch in the release phase you get:

if touch(press) - do nothing

if swipe right - do task B

if release - do task A

etc.

 

If they touch(press) and release then no swipe event is registered and Task A will be triggered. If they touch(press) and swipe then Task B will be triggered.

 

So how do you cancel a specific event? I have not found a way to programmatically cancel an event other than … just do nothing. Also you can set up a flag that detects if Task B was performed then don’t perform Task A (if a release is detected) based on the flag.

 

Let me know how it works for you.

 

Theo