Hello Guest

Author Topic: ScrollableArea disable while touching  (Read 3956 times)

wintermute

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
ScrollableArea disable while touching
« on: July 25, 2013, 06:15:34 am »
Hello,

So I'm trying to code something like dragging an item out of a scrollable area. What I do is if I touch something in the scrollable area for more than 0.5 seconds, I disable the scrollable area and create a new "fake" object to drag around the screen. After releasing that object (touch up or mouse button up), I re-enable the scrollable area.

I think I've found a bug.

When a touch is active (i.e. i'm currently scrolling it) then I disable the tk2dScrollableArea script. The variable
Code: [Select]
isSwipeScrollingInProgress is still true. However on the
Code: [Select]
OnDisable() method, you unsubscribe to OnInputUpdate via
Code: [Select]
tk2dUIManager.Instance.OnInputUpdate -= BackgroundOverUpdate;
So next time I enable it it won't register to the to the line
Code: [Select]
tk2dUIManager.Instance.OnInputUpdate += BackgroundOverUpdate; in
Code: [Select]
BackgroundButtonDown()
So when I enabled it, it won't scroll anymore.

Is this a bug or is this intended behaviour? Please advise, thanks!
« Last Edit: July 25, 2013, 06:18:15 am by wintermute »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: ScrollableArea disable while touching
« Reply #1 on: July 25, 2013, 01:50:43 pm »
No, it isn't intended, but neither did we foresee anyone doing what you're using it for :)
Good find with the bug, and thanks for reporting it.

It should check for and clear both isBackgroundButtonDown and isSwipeScrollingInProgress, so it should read:

Code: [Select]
        if (isBackgroundButtonDown || isSwipeScrollingInProgress)
        {
            if (tk2dUIManager.Instance != null)
            {
                tk2dUIManager.Instance.OnInputUpdate -= BackgroundOverUpdate;
            }
            isBackgroundButtonDown = false;
            isSwipeScrollingInProgress = false;
        }

wintermute

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: ScrollableArea disable while touching
« Reply #2 on: July 25, 2013, 03:04:16 pm »
Applied your code fix, works now. Thank you!

jaz1974

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: ScrollableArea disable while touching
« Reply #3 on: September 23, 2013, 10:11:05 am »
Hi guys,

Sorry to hijack the thread slightly, but I was hoping you might help me on this one?


Any chance you could explain how you are doing the 'if pressed for more than 0.5 secs' part?

I'm a bit of a noob and I'm struggling.

Cheers!

Jaz