tableView's onRowTouch fires two times if tap just a bit above the line (row separator)

Hi,

I am not sure if this is a bug or some sorts of quick tap. If I tap (using mouse pointer) just a bit above the line (row separator) then the onRowTouch will fire two times. I can reproduce this on computer with “tap” phase but haven’t been able to do it on device yet and so far I can’t reproduce with “press” and “release” phase either. 

This is the code:

local widget = require( "widget" ) local function onRowTouch(event) local phase = event.phase local row = event.target if event.phase == "tap" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) end end -- Create the widget local tableView = widget.newTableView { left = 0, top = 0, height = display.contentHeight, width = display.contentWidth, onRowRender = onRowRender, onRowTouch = onRowTouch, listener = scrollListener } for i = 1, 5 do -- Insert a row into the tableView tableView:insertRow{} end

My build is 2646 and I’ve tried 2702 too, same result. Wonder if this is a bug or normal behavior due to imperfect tap.

Thanks,

So Lin 

Im not filly sure on what your problem is but from what i understand adding a 

return true

 might help : like this

local function onRowTouch(event) local phase = event.phase local row = event.target if event.phase == "press" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) end return true end

Good Luck!

Hi,

It still fires two times even with 

return true

See the console log below:

2015-09-09 08:58:19.182 Corona Simulator[439:7483] Row Index: 3 2015-09-09 08:58:19.182 Corona Simulator[439:7483] Row Index: 2

I just tap once but the event fired two time and time stamp is exactly the same.

Corona people, any idea?

Thanks,

So Lin

Hey, So try this…

local function onRowTouch(event) local row = event.target if event.phase == "began" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) elseif event.phase == "ended" then print("hello") end return true end

You might not even need return true.

If this is for the PC or MAC then the event.phases woudl be like this

local function onRowTouch(event) local row = event.target if event.phase == "down" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) elseif event.phase == "up" then print("hello") end return true end

And what is your event listener?

Hi,

event.phase doesn’t have “began” and “ended”.

onRowTouch (optional)

Listener. The function used to listen for TableView touch/tap events. In this listener function, the event.phase values include “tap”, “press”,“release”, “swipeLeft”, and “swipeRight”. In addition, event.target is a reference to the row that was interacted with andevent.target.index is the index number of that row.

So far, no problem with “press” and “release”.

Thanks,

So Lin

I’m on MAC.

What do you mean event.phase doesnt have began and ended…

https://docs.coronalabs.com/api/event/touch/phase.html

Whats your question again? Im lost…

I’m using tableView widget. You can read my first post again :slight_smile:

Thanks,

So Lin

Hi So Lin,

So, you’re tapping specifically inside the divider line, not even 1-2 pixels outside of it?

Brent

As a side note, I personally never use the built-in divider lines with tableViews… I merely render my own lines (or alternate the row colors slightly) within each row. Of course, if the divider line IS registering a tap on consecutive rows, we’ll need to investigate why…

Brent

Hi Brent,

It can be reproduced on computer (I’m using MAC). Just point the mouse pointer a bit above the divider line and tap. It seems to be ok on device anyway.

Thanks,

So Lin

Hi So Lin,

I was able to reproduce this… well, only in the Simulator, but that means it could potentially occur on a device.

In any case, I should have a fix for this included in an upcoming daily build.

Thanks,

Brent

Hi Brent,

Thank you for looking into this. Even if it only happens with Simulator, it should be fixed because it may cause confusion and debugging headache.

Thanks,
So Lin

Hi So Lin,

The fix should be in the next daily build (#2709; check the notes though). If you find that this still doesn’t resolve the issue, please post back here.

Brent

Im not filly sure on what your problem is but from what i understand adding a 

return true

 might help : like this

local function onRowTouch(event) local phase = event.phase local row = event.target if event.phase == "press" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) end return true end

Good Luck!

Hi,

It still fires two times even with 

return true

See the console log below:

2015-09-09 08:58:19.182 Corona Simulator[439:7483] Row Index: 3 2015-09-09 08:58:19.182 Corona Simulator[439:7483] Row Index: 2

I just tap once but the event fired two time and time stamp is exactly the same.

Corona people, any idea?

Thanks,

So Lin

Hey, So try this…

local function onRowTouch(event) local row = event.target if event.phase == "began" then local rowIndex = event.target.index print("Row Index: " .. rowIndex) elseif event.phase == "ended" then print("hello") end return true end

You might not even need return true.