Improved early failing strategy implementation

as in iOS UIGestureRecognizers. Also fixes bugs with new validating state machine.
This commit is contained in:
Pavel fljot 2012-07-04 23:43:01 +03:00
parent 6273cc33e6
commit 2e02b13581
8 changed files with 21 additions and 22 deletions

View file

@ -367,6 +367,19 @@ package org.gestouch.gestures
}
protected function failOrIgnoreTouch(touch:Touch):void
{
if (state == GestureState.POSSIBLE)
{
setState(GestureState.FAILED);
}
else if (state != GestureState.IDLE)
{
ignoreTouch(touch);
}
}
[Abstract]
/**
* <p><b>NB!</b> This is abstract method and must be overridden.</p>

View file

@ -84,14 +84,7 @@ package org.gestouch.gestures
{
if (touchesCount > numTouchesRequired)
{
if (state == GestureState.BEGAN || state == GestureState.CHANGED)
{
ignoreTouch(touch);
}
else
{
setState(GestureState.FAILED);
}
failOrIgnoreTouch(touch);
return;
}

View file

@ -116,15 +116,14 @@ package org.gestouch.gestures
{
if (touchesCount > maxNumTouchesRequired)
{
//TODO
ignoreTouch(touch);
failOrIgnoreTouch(touch);
return;
}
if (touchesCount >= minNumTouchesRequired)
{
updateLocation();
}
}
}

View file

@ -60,8 +60,7 @@ package org.gestouch.gestures
{
if (touchesCount > 2)
{
//TODO
ignoreTouch(touch);
failOrIgnoreTouch(touch);
return;
}

View file

@ -78,8 +78,7 @@ package org.gestouch.gestures
{
if (touchesCount > numTouchesRequired)
{
//TODO: or ignore?
setState(GestureState.FAILED);
failOrIgnoreTouch(touch);
return;
}

View file

@ -93,9 +93,7 @@ package org.gestouch.gestures
{
if (touchesCount > numTouchesRequired)
{
// We put more fingers then required at the same time,
// so treat that as failed
setState(GestureState.FAILED);
failOrIgnoreTouch(touch);
return;
}

View file

@ -66,8 +66,7 @@ package org.gestouch.gestures
{
if (touchesCount > 2)
{
//TODO: to ignore or to keep this touch somewhere?
ignoreTouch(touch);
failOrIgnoreTouch(touch);
return;
}

View file

@ -60,8 +60,7 @@ package org.gestouch.gestures
{
if (touchesCount > 2)
{
//TODO
ignoreTouch(touch);
failOrIgnoreTouch(touch);
return;
}