event priority - scrolling issue - buttons or images in a tableView, scroll ability lost.

Hi all,

I’ve got a really cool tableView now, with 2 buttons on each row. These buttons are “tiles” that take up the whole row together (50% display width each). 
I want to be able to scroll the tableview up and down, as well as “tap” the buttons. 

If I understand correctly, in corona, the underlying tableview should be able to receiving the presses on the buttons… but as soon as my buttons are rendered, I loose the ability to scroll the tableView.

I’ve tried using button widgets, with onPress, onEvent, onRelease and none have made any difference. 

I tried switching to display.newImageRect instead of buttons, and adding a listener… but still cant do this. 

Can anyone help or is this impossible?

I’m guessing the answer lies in “event.phase”

Any help, gratefully appreciated

I solved this myself in the end, i switched to a combination of imageRect’s instead of buttons, and listeners for touch and tap to do different things. Works a treat.

The way I do it is to use add a touch event to my button instead of a tap, then use takeFocus to move the touch focus to the scrollview:

local function myButtonTouchFunction(event) if event.phase == "began" then elseif event.phase == "moved" then local dx = math.abs( event.x - event.xStart ) local dy = math.abs( event.y - event.yStart ) -- if finger drags button more than 5 pixels, pass focus to scrollView if dx \> 5 or dy \> 5 then buttonScrollView:takeFocus( event ) end elseif event.phase == "ended" then myButtonTapFunction() end return true end 

I solved this myself in the end, i switched to a combination of imageRect’s instead of buttons, and listeners for touch and tap to do different things. Works a treat.

The way I do it is to use add a touch event to my button instead of a tap, then use takeFocus to move the touch focus to the scrollview:

local function myButtonTouchFunction(event) if event.phase == "began" then elseif event.phase == "moved" then local dx = math.abs( event.x - event.xStart ) local dy = math.abs( event.y - event.yStart ) -- if finger drags button more than 5 pixels, pass focus to scrollView if dx \> 5 or dy \> 5 then buttonScrollView:takeFocus( event ) end elseif event.phase == "ended" then myButtonTapFunction() end return true end 

Thanks @AlanPlantPot, that worked perfectly.

Thanks @AlanPlantPot, that worked perfectly.