Table View with UI buttons

I’m trying to use the tableView library with the ui library and I can’t get them to work together. Basically I want objects that are clickable and able to scroll.

I attached a very simple test project that I made to clearly show the issue. There are a few other libraries included, but that is only to stay consistent with the code I’m using for my game. You can view the code for the scrolling objects under MainMenu.lua. You can see that currently, the objects are scrolling fine. However, if you comment out the newImageRect code and uncomment the ui button code, the objects will fail to scroll. The simulator only gets the touch input for the button and not the drag (scroll).

If anyone could help me out with this issue I would greatly appreciate it.

Thanks,

Garrett

Hi Garrett.  Welcome to the forums.  You might get some help from the community, but you have a couple of things going on.

First ui.lua is deprecated.  We would prefer you use the widget.newButton() API call which is part of the widget library.  Secondly. your tableView.lua is a pre-Widgets 1.0 version from when we were first messing with this.  We are now at Widgets 2.0 and can’t really support that version since we’ve deprecated it a long time ago.   Consider using widget.newTableView() instead, also part of the widget library.  Be warned, tableView’s have changed considerably, expect some learning curve with them.

With all of that out of the way.  Putting buttons in tableView rows is tricky because the row wants to handle touch and tap events as well as  you needing them for the buttons.   Part of the trickyness is lets say you have a Play button in the row and you set it up to respond to touch.  Well it gets and handles the touch event, but a tap event still makes it to the row behind it which will want to respond to the tap as well.  This week’s blog post covers this issue:
 

http://www.coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

It can be done, but it’s tricky.

Hi Garrett.  Welcome to the forums.  You might get some help from the community, but you have a couple of things going on.

First ui.lua is deprecated.  We would prefer you use the widget.newButton() API call which is part of the widget library.  Secondly. your tableView.lua is a pre-Widgets 1.0 version from when we were first messing with this.  We are now at Widgets 2.0 and can’t really support that version since we’ve deprecated it a long time ago.   Consider using widget.newTableView() instead, also part of the widget library.  Be warned, tableView’s have changed considerably, expect some learning curve with them.

With all of that out of the way.  Putting buttons in tableView rows is tricky because the row wants to handle touch and tap events as well as  you needing them for the buttons.   Part of the trickyness is lets say you have a Play button in the row and you set it up to respond to touch.  Well it gets and handles the touch event, but a tap event still makes it to the row behind it which will want to respond to the tap as well.  This week’s blog post covers this issue:
 

http://www.coronalabs.com/blog/2013/10/01/tutorial-taptouch-anatomy/

It can be done, but it’s tricky.