2D Toolkit Forum
2D Toolkit => Support => Topic started by: wintermute 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 isSwipeScrollingInProgress is still true. However on the OnDisable() method, you unsubscribe to OnInputUpdate via tk2dUIManager.Instance.OnInputUpdate -= BackgroundOverUpdate;
So next time I enable it it won't register to the to the line tk2dUIManager.Instance.OnInputUpdate += BackgroundOverUpdate; in BackgroundButtonDown()
So when I enabled it, it won't scroll anymore.
Is this a bug or is this intended behaviour? Please advise, thanks!
-
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:
if (isBackgroundButtonDown || isSwipeScrollingInProgress)
{
if (tk2dUIManager.Instance != null)
{
tk2dUIManager.Instance.OnInputUpdate -= BackgroundOverUpdate;
}
isBackgroundButtonDown = false;
isSwipeScrollingInProgress = false;
}
-
Applied your code fix, works now. Thank you!
-
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