Support => NGUI 3 Support => Topic started by: ronronmx on April 16, 2013, 11:09:46 PM
Title: Event for Drag ended?
Post by: ronronmx on April 16, 2013, 11:09:46 PM
Hey guys, I use the "OnDrag" Event Listener to detect when I'm dragging on a UI element (not drag & drop, just dragging over an area), and I need to know when the Drag ends, for example, when the user lifts its finger. I know about the "OnDrop" and "OnDragFinished" events, but those are part of the UIEventListener class like the "OnDrag" one, and are mostly for detecting when the user drops whatever object he was "moving" correct?
There is no "OnDragEnded" or "OnDragFinished" that use the "UIEventListener" class, so how can I achieve this? Do I have to use the "OnPress" event to detect when the Drag ends?
Thanks in advance! Stephane
Title: Re: Event for Drag ended?
Post by: Nicki on April 17, 2013, 03:36:15 AM
Here's a way:
bool wasDragging =false;
void OnPress(bool pressed)
{
if(!pressed && wasDragging)
{
wasDragging =false;
//do onDragEnded stuff
}
}
void OnDrag(Vector2 delta)
{
wasDragging =true;
}
Title: Re: Event for Drag ended?
Post by: ronronmx on April 17, 2013, 10:48:20 AM