Author Topic: Scroll View is wired if UICamera 's Sticky Press is set to false  (Read 13247 times)

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Scroll View is wired if UICamera 's Sticky Press is set to false

I am using the NGUI Example 7 - Scroll View (Panel).
« Last Edit: June 14, 2013, 10:34:02 AM by yuewah »

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #1 on: June 16, 2013, 01:04:52 AM »
@ArenMook, If Stick Press is set to false, the Scroll View will be bounding abnormally when dragging.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #2 on: June 16, 2013, 09:57:23 PM »
Find the part that begins with
  1. if (!stickyPress && !unpressed && currentTouch.pressStarted && currentTouch.pressed != hoveredObject)
in UICamera, and replace it with
  1. if (currentTouch.clickNotification != ClickNotification.None)
  2. {
  3.         // If the user is pressing down and has dragged the touch away from the original object,
  4.         // unpress the original object and notify the new object that it is now being pressed on.
  5.         if (!stickyPress && !unpressed && currentTouch.pressStarted && currentTouch.pressed != hoveredObject)
  6.         {
  7.                 isDragging = true;
  8.                 Notify(currentTouch.pressed, "OnPress", false);
  9.                 currentTouch.pressed = hoveredObject;
  10.                 Notify(currentTouch.pressed, "OnPress", true);
  11.                 isDragging = false;
  12.         }
  13. }

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #3 on: June 17, 2013, 08:36:45 AM »
Will you include this in next release ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #4 on: June 17, 2013, 09:49:37 PM »
It's a part of it, yes.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #5 on: June 18, 2013, 01:17:13 AM »
When StickyPress is set to false, and a button contains UIButtonMessage and UIEventListener, when drag from outside and drop to the button, it throws error "Failed to call function OnDrop of class UIEventListener
Calling function OnDrop with no parameters but the function requires 1."

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #6 on: June 18, 2013, 02:42:03 AM »
Btw, If I start drag from outside through over UIButton, It will notify OnPress Message. I think it will confuse user that they  are clicked on the button.

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #7 on: September 16, 2013, 03:55:49 AM »
When StickyPress is set to false, and a button contains UIButtonMessage and UIEventListener, when drag from outside and drop to the button, it throws error "Failed to call function OnDrop of class UIEventListener
Calling function OnDrop with no parameters but the function requires 1."

I´m having the same issue even using ArenMook "Patch" (if (currentTouch.clickNotification != ClickNotification.None)).

 I´m using 2.6.5b.

Thanks

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #8 on: September 16, 2013, 05:43:39 AM »
The way stickyPress=false works is sort of a mess and I would seriously recommend not using it.

I will see if I can change it to be the way that one would expect when I have time, but it likely requires some tinkering under the surface, which I'd rather not do.

hellaandrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #9 on: July 28, 2014, 05:23:43 PM »
I was trying to find a solution that didn't require setting the Sticky Press option to false, mainly due to the issues it causes with scrollviews.

What I came up with was just setting the stickyPress boolean to false when the OnPress function is triggered, then set it back to true when OnPress is false.

PS. At my work, we are using an older version of NGUI, only because we're so dug in with this version and can't afford to change anything at this point. I'm not too sure which version we are on or whether or not this sort of issue has been fixed in newer versions, but this seemed to work for me.

  1. UICamera uiCamera;
  2.  
  3. void Start ()
  4.         {
  5.                 uiCamera = GameObject.FindObjectOfType<UICamera>();
  6.         }
  7.  
  8. void OnPress (bool isPressed)
  9.         {
  10.                 if (isPressed)
  11.                 {      
  12.                         uiCamera.stickyPress = false;
  13.                         // Do whatever you need to do here.
  14.                 }
  15.                 else
  16.                 {
  17.                         uiCamera.stickyPress = true;
  18.                 }
  19.         }
  20.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View is wired if UICamera 's Sticky Press is set to false
« Reply #10 on: July 29, 2014, 03:26:57 AM »
Sticky press doesn't exist anymore. It was removed a long time ago.