mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-27 01:35:40 -05:00
Implement touch cancelation handling
This commit is contained in:
parent
7bfb1fae36
commit
9c817b7472
2 changed files with 43 additions and 1 deletions
|
@ -313,7 +313,20 @@ package org.gestouch.core
|
||||||
|
|
||||||
gestouch_internal function onTouchCancel(touch:Touch):void
|
gestouch_internal function onTouchCancel(touch:Touch):void
|
||||||
{
|
{
|
||||||
//TODO
|
var gesturesForTouch:Vector.<Gesture> = _gesturesForTouchMap[touch] as Vector.<Gesture>;
|
||||||
|
var gesture:Gesture;
|
||||||
|
var i:uint = gesturesForTouch.length;
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
gesture = gesturesForTouch[i];
|
||||||
|
|
||||||
|
if (!_dirtyGesturesMap[gesture] && gesture.isTrackingTouch(touch.id))
|
||||||
|
{
|
||||||
|
gesture.touchCancelHandler(touch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gesturesForTouch.length = 0;// release for GC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -407,6 +407,14 @@ package org.gestouch.gestures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function onTouchCancel(touch:Touch):void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function setState(newState:GestureState):Boolean
|
protected function setState(newState:GestureState):Boolean
|
||||||
{
|
{
|
||||||
if (_state == newState && _state == GestureState.CHANGED)
|
if (_state == newState && _state == GestureState.CHANGED)
|
||||||
|
@ -576,6 +584,27 @@ package org.gestouch.gestures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gestouch_internal function touchCancelHandler(touch:Touch):void
|
||||||
|
{
|
||||||
|
delete _touchesMap[touch.id];
|
||||||
|
_touchesCount--;
|
||||||
|
|
||||||
|
onTouchCancel(touch);
|
||||||
|
|
||||||
|
if (!state.isEndState)
|
||||||
|
{
|
||||||
|
if (state == GestureState.BEGAN || state == GestureState.CHANGED)
|
||||||
|
{
|
||||||
|
setState(GestureState.CANCELLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setState(GestureState.FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function gestureToFail_stateChangeHandler(event:GestureStateEvent):void
|
protected function gestureToFail_stateChangeHandler(event:GestureStateEvent):void
|
||||||
{
|
{
|
||||||
if (!_pendingRecognizedState || state != GestureState.POSSIBLE)
|
if (!_pendingRecognizedState || state != GestureState.POSSIBLE)
|
||||||
|
|
Loading…
Reference in a new issue