Buttons In Scrollview Not Registering Tap Correctly

Hi there,

I’m having some issues with the new Widget 2.0 with button taps being registered properly when the buttons are housed within a scrollview.

If you tap incredibly quickly or move your finger a tiny fraction (which a lot of people do by accident), a scroll is registered rather than a button press. I didn’t originally see it as an issue as I tend to tap fairly firmly and hold that tap for a split second. But a few customers have mentioned that the buttons aren’t registering their taps and I suspect it’s because they’re tapping too quickly or moving their finger slightly during the tap process.

With the old ScrollView / Button I was using (before Widget 2.0), I put a bit of code within the “move” phase of the button handler which checked how far a user had moved their finger and passed focus back to the ScrollView if it was beyond a certain amount. This was great because I could decide the amount of movement I allowed before it became a “scroll” rather than a “tap”. The code I was using was very similar to that between lines 12 and 18 of this piece of code - https://gist.github.com/jonbeebe/1590908 using takeFocus (which is no longer supported). I found the standard 5 pixels of movement too little so changed it to 8 which worked better (my apps are for children so their tapping tends to be a little less precise).

I can no longer do that as far as I can tell, so I’m stuck with what Corona decided and it’s not working for some people.

Is there a way round this so I can get control of the amount of movement allowed before a scroll is registered rather than a button tap?

Also, is there a way of saying that any tap is a tap until movement beyond a certain amount occurs and then it’s a scroll? That would solve the very quick taps not being registered too I presume.

I really don’t want to go back to the old way of doing things as a.) it would take forever to replace all the new Widget 2 buttons and scrollViews and b.) I’d rather be using the most recent Corona code for the sake of future support etc.

Thanks in advance for any help.

All the best,

Ian

I am also having trouble with this. I asked about it in another post but have not got a response. Hopefully they find time to address this soon. Nearly impossible to work with a scrolling list of different buttons.

Are you using widget.newButton in the scrollView?

In a client app of mine, I just had images for buttons, and I added my own touch handler to the graphic and I can control my own move action on the button before passing it on to the scrollView.

Thanks Rob - I am using widget.newButton, yes.

Prior to that I was using my own buttons with their own touch handlers but the problem I had was passing focus back to the scrollView.

This code…

scroller:takeFocus( event )

has now been removed from Corona so it doesn’t work any more, which is why I moved over to the widget buttons.

How are you passing focus back to your scroller?

Surely though, the widget buttons should work effectively if they’re part of the widget library which also contains the scrollview, especially as the documentation says this should work. Either I’m missing something or the widget buttons interaction with the scrollview needs reworking. Hopefully I’m missing something as I imagine that would be a simpler solution :wink:

Thanks,

Ian

P.S - Mattgames I have subscribed to your thread too - hopefully between them we’ll find a solution.

Add code similar to this:

[lua]

            elseif event.phase == “moved” then – Check if you moved your finger while touching
                local dx = math.abs( event.x - event.xStart ) – Get the x-transition of the touch-input
                local dy = math.abs( event.y - event.yStart ) – Get the y-transition of the touch-input
                if dx > 5 or dy > 5 then
                    display.getCurrentStage():setFocus( nil )
                    event.target.isFocus = false                 
                    event.target = scrollView._view
                    event.phase = “began”
                    scrollView._view.touch( scrollView._view, event )
                    --scrollView:takeFocus( event ) – the above lines fake takeFocus()

               end
            end

[/lua]

Hi Rob,

Thanks for the reply. This works as a temporary fix but I don’t understand why the new widget buttons don’t work correctly in the widget scrollView?

Surely if they’re both meant to be part of a working widget library then they should function correctly together, especially as the documentation bills the buttons as working in scrollViews.

Is there any plan to fix this soon? It’s really clunky as it is currently and I’ve spent a while replacing all my old buttons with the new widget ones only to find I’ve now got to change everything back because it doesn’t work properly - frustrating to say the least. I can’t use the new buttons in the scrollViews as customers are complaining that the buttons aren’t registering touches properly (see my original post).

A solution would be most welcome. Can something like the above code you posted be incorporated into the button widget with settable values for dx and dy?

Thanks,

Ian

+1 This is very important, especially since the documentation is says it is working. I too reworked a bunch of my code to find out this was not working correctly.

I am also having trouble with this. I asked about it in another post but have not got a response. Hopefully they find time to address this soon. Nearly impossible to work with a scrolling list of different buttons.

Are you using widget.newButton in the scrollView?

In a client app of mine, I just had images for buttons, and I added my own touch handler to the graphic and I can control my own move action on the button before passing it on to the scrollView.

Thanks Rob - I am using widget.newButton, yes.

Prior to that I was using my own buttons with their own touch handlers but the problem I had was passing focus back to the scrollView.

This code…

scroller:takeFocus( event )

has now been removed from Corona so it doesn’t work any more, which is why I moved over to the widget buttons.

How are you passing focus back to your scroller?

Surely though, the widget buttons should work effectively if they’re part of the widget library which also contains the scrollview, especially as the documentation says this should work. Either I’m missing something or the widget buttons interaction with the scrollview needs reworking. Hopefully I’m missing something as I imagine that would be a simpler solution :wink:

Thanks,

Ian

P.S - Mattgames I have subscribed to your thread too - hopefully between them we’ll find a solution.

Sorry to bump this but I’ve seen no response on this (or any of the similar threads) from anyone at Corona and as Matt says, the documentation says it’s working but it isn’t.

I know there are workarounds but for me to go through and implement them is a real pain as I’ve already replaced all my original custom image buttons with the new widget buttons (having been led to believe they would work) and now I’m essentially being told to go back and “unchange” them all just to get basic scrolling functionality working with any scrollView with buttons in!

If there’s anything that can be done, ASAP, to make the widget buttons work correctly in a widget scrollView that would be great. I know you guys are busy but I’m struggling to see what the point of redoing everything to Widget 2.0 was if this simple thing isn’t working properly.

Thanks,

Ian

Struggling with this too. Incurring extra $$$ costs having my developer troubleshoot and implement your workaround.

Add code similar to this:

[lua]

            elseif event.phase == “moved” then – Check if you moved your finger while touching
                local dx = math.abs( event.x - event.xStart ) – Get the x-transition of the touch-input
                local dy = math.abs( event.y - event.yStart ) – Get the y-transition of the touch-input
                if dx > 5 or dy > 5 then
                    display.getCurrentStage():setFocus( nil )
                    event.target.isFocus = false                 
                    event.target = scrollView._view
                    event.phase = “began”
                    scrollView._view.touch( scrollView._view, event )
                    --scrollView:takeFocus( event ) – the above lines fake takeFocus()

               end
            end

[/lua]

Still wondering what the situation is with this? If anyone from Corona could shed some light on when there’s likely to be a fix I would really appreciate it.

Thanks,

Ian

Hey guys, the takeFocus() method for scrollViews is coming back, please see my post here: http://forums.coronalabs.com/topic/33579-info-scrollview-take-focus-is-coming-back/

Hi Rob,

Thanks for the reply. This works as a temporary fix but I don’t understand why the new widget buttons don’t work correctly in the widget scrollView?

Surely if they’re both meant to be part of a working widget library then they should function correctly together, especially as the documentation bills the buttons as working in scrollViews.

Is there any plan to fix this soon? It’s really clunky as it is currently and I’ve spent a while replacing all my old buttons with the new widget ones only to find I’ve now got to change everything back because it doesn’t work properly - frustrating to say the least. I can’t use the new buttons in the scrollViews as customers are complaining that the buttons aren’t registering touches properly (see my original post).

A solution would be most welcome. Can something like the above code you posted be incorporated into the button widget with settable values for dx and dy?

Thanks,

Ian

+1 This is very important, especially since the documentation is says it is working. I too reworked a bunch of my code to find out this was not working correctly.

Sorry to bump this but I’ve seen no response on this (or any of the similar threads) from anyone at Corona and as Matt says, the documentation says it’s working but it isn’t.

I know there are workarounds but for me to go through and implement them is a real pain as I’ve already replaced all my original custom image buttons with the new widget buttons (having been led to believe they would work) and now I’m essentially being told to go back and “unchange” them all just to get basic scrolling functionality working with any scrollView with buttons in!

If there’s anything that can be done, ASAP, to make the widget buttons work correctly in a widget scrollView that would be great. I know you guys are busy but I’m struggling to see what the point of redoing everything to Widget 2.0 was if this simple thing isn’t working properly.

Thanks,

Ian

Struggling with this too. Incurring extra $$$ costs having my developer troubleshoot and implement your workaround.

Still wondering what the situation is with this? If anyone from Corona could shed some light on when there’s likely to be a fix I would really appreciate it.

Thanks,

Ian