mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2025-03-24 19:19:42 -04:00
Gesture#shouldTrackTouchPoint() is no more abstract method but rather has some default functionality.
Since most of the gestures requires touch point (on touch begin) to be on top of the target, this common logic moved to base class Gesture.
This commit is contained in:
parent
c3d637b4a7
commit
d65cf3ac90
7 changed files with 48 additions and 157 deletions
|
@ -1,17 +1,16 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Timer;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.DoubleTapGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Timer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -110,24 +109,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, touchPoint:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
|
|
@ -5,10 +5,8 @@ package org.gestouch.gestures
|
|||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.DragGestureEvent;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
|
@ -67,24 +65,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import org.gestouch.events.GestureTrackingEvent;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GestureEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.system.Capabilities;
|
||||
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.IGesture;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.GestureTrackingEvent;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.GestureEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.system.Capabilities;
|
||||
|
||||
|
||||
[Event(name="gestureTrackingBegin", type="org.gestouch.events.GestureTrackingEvent")]
|
||||
|
@ -218,23 +219,32 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
/**
|
||||
* Used by GesturesManager to check wether this gesture is interested in
|
||||
* tracking this touch point upon this event (of type TouchEvent.TOUCH_BEGIN).
|
||||
*
|
||||
* <p>Most of the gestures check, if event.target is target or target contains event.target</p>
|
||||
* <p>Most of the gestures check, if event.target is target or target contains event.target.</p>
|
||||
*
|
||||
* <p>No need to use it directly.</p>
|
||||
*
|
||||
* <p><b>NB!</b> This is abstract method and must be overridden.</p>
|
||||
*
|
||||
* @see org.gestouch.core.GesturesManager
|
||||
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TouchEvent.html
|
||||
*/
|
||||
public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
throw Error("shouldTrackPoint() is abstract method and must be overridden.");
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//By default gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.utils.Timer;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.LongPressGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -73,25 +72,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import org.gestouch.GestureUtils;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.RotateGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -70,25 +69,6 @@ package org.gestouch.gestures
|
|||
return RotateGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
//FIXME?
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
import org.gestouch.Direction;
|
||||
import org.gestouch.GestureUtils;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
|
@ -14,6 +7,11 @@ package org.gestouch.gestures
|
|||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.SwipeGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
|
||||
/**
|
||||
* SwipeGesture detects <i>swipe</i> motion (also known as <i>flick</i> or <i>flig</i>).
|
||||
|
@ -74,24 +72,6 @@ package org.gestouch.gestures
|
|||
return SwipeGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.ZoomGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -62,25 +61,6 @@ package org.gestouch.gestures
|
|||
return ZoomGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
//FIXME?
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue