Author Topic: How to scrollView by two Fingers instead one?  (Read 5413 times)

macxiao126

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
How to scrollView by two Fingers instead one?
« on: May 21, 2014, 10:42:32 AM »
Hi,

I noticed that NGUI's touch system was wrapped by functions such as OnPress,OnDrag or something else.But when I use scrollView(the Panel way),I found that I just can use one finger to drag.But what I really want to do is drag by two finger instead one finger.

So how can I approach it?How to custom the drag function?

Best Regards.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to scrollView by two Fingers instead one?
« Reply #1 on: May 21, 2014, 12:20:40 PM »
Multi-touch would fall under gesture recognition, which NGUI doesn't do. You could check to see how many touches are active though (UICamera.touchCount), and only perform the drag if there are 2 touches and they are within close proximity of each other... but it would be better to have proper gesture recognition, and using UICamera's onCustomInput functionality. Is there any particular reason why you want it scrollable with two fingers instead of one?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to scrollView by two Fingers instead one?
« Reply #2 on: May 21, 2014, 04:45:30 PM »
Instead of having the colliders point to the scrollview directly, you would have to filter it through your own touch receiver class, that could check for double touches - if both drag (or whatever other parameters you'd want) then pass along the OnPress and OnDrag to the scrollview.

macxiao126

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: How to scrollView by two Fingers instead one?
« Reply #3 on: May 21, 2014, 09:53:13 PM »
Because in my game,there is a more fundamental operation should use one finger touch and drag on scroll view.Can I pass my gesture recognized by EasyTouch to OnDrag during onCustomInput? Thanks. 
Multi-touch would fall under gesture recognition, which NGUI doesn't do. You could check to see how many touches are active though (UICamera.touchCount), and only perform the drag if there are 2 touches and they are within close proximity of each other... but it would be better to have proper gesture recognition, and using UICamera's onCustomInput functionality. Is there any particular reason why you want it scrollable with two fingers instead of one?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to scrollView by two Fingers instead one?
« Reply #4 on: May 22, 2014, 02:44:57 PM »
You can create a new "touch" of your own using onCustomInput. Just look at UICamera's existing event processing functions like UICamera.ProcessTouch or ProcessOthers. The best example to use though is probably UICamera.ProcessFakeTouches.