Hello Guest

Author Topic: tk2dUIItems register OnClickUIItem but send swipe to tk2dUIScrollableArea  (Read 4944 times)

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
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.

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
... 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Hi,

What platform is this on?

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Happening just in the editor (Mac), but also on Android / iOS.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
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).

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
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?

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
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.