2D Toolkit Forum

2D Toolkit => Support => Topic started by: zblack on March 28, 2015, 05:36:03 pm

Title: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: zblack on March 28, 2015, 05:36:03 pm
This is happening randomly (but frequently) in the "5 - ScrollableArea" test demo scene. If I swipe very quickly I get the scroll area moving but also get a click event on my uiItems.
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: zblack on March 28, 2015, 06:04:54 pm
... It also happens when the area is scrolling (drifting) and you tap to stop it. The scroll area stops but it also registers a click with any uiItems in the container.
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: unikronsoftware on March 29, 2015, 11:40:20 pm
Hi,

What platform is this on?
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: zblack on March 30, 2015, 02:32:18 am
Happening just in the editor (Mac), but also on Android / iOS.
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: unikronsoftware on March 31, 2015, 10:40:31 pm
How do you reproduce this in the editor, and what version of Unity? I've been trying in Unity 4.63 and I can't reproduce this. I can do the thing where you stop it and it registers a click - that is intended, but I don't get the click on swipe (This would be worrying in a scene that is so simple).
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: zblack on April 01, 2015, 01:19:06 am
4.6.3f1. All I did was add a OnClickUIItem listener script, a tk2dUIItem script, and a box collider to the Portrait object of the ItemTemplate. If you click and then release while swiping, it will register a click and also swipe the scroll area. Also, I don't feel that stopping the scroll area should register a click on an item. The iOS user interface does not behave this way. Are you first capturing events in the children and then passing up to the parent?
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: unikronsoftware on April 01, 2015, 07:50:41 am
Do you have  isChildOfAnotherUIItem ticked on the ui item? Eg. on the "Add more" button, as soon as you move beyond a certain threshold it cancels the click. Am I missing something obvious here?
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: zblack on April 02, 2015, 04:16:38 am
https://www.dropbox.com/sh/g9ww977u95okyms/AACfpc_4mZCjKDsVuiWRzvLla?dl=0

You can see on the last 2 of 3 clicks/swipes. (I don't know why each click is triggering 2 prints to the output log). This behavior is even more pronounced in the app I'm working on. Perhaps the framerate is lower because of its complexity, but I almost can't scroll without accidentally triggering a click. Happens about 1 in 4 swipes.
Title: Re: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea
Post by: unikronsoftware on April 06, 2015, 01:42:09 pm
Hey only just had a chance to look at this - it looks like if the swipe velocity was lower than the scroll threshold it could start moving + click at the same time. The whole thing really needs a rewrite at some point, its not ideal how it does some things in there (eg. velocity drop instead of exponential decay to spring into place, but thats a story for another day).

Line 454, tk2dUIScrollableArea -
                else if (swipeCurrVelocity != 0 && isSwipeScrollingInProgress) //velocity scrolling
Add the condition to only swipe when velocity > 0, isSwipeScrollingInProgress only becomes true once the touch is cancelled. It should help in your case.

It doesn't happen anywhere near as frequently as it does for you, for me its like 1 in every 20 swipes. But that could be down to framerate, etc.