Packagefeathers.utils.touch
Classpublic class LongPress
InheritanceLongPress Inheritance Object

Product Version : Feathers 2.3.0

Dispatches FeathersEventType.LONG_PRESS from the target when the target is long-pressed. Conveniently handles all TouchEvent listeners automatically. Useful for custom item renderers that should dispatch a long press event.

In the following example, a custom item renderer will dispatch a long press event when tapped:

public class CustomItemRenderer extends LayoutGroupListItemRenderer
{
    public function CustomItemRenderer()
    {
        super();
        this._longPress = new LongPress(this);
    }
    
    private var _longPress:LongPress;
}

Note: When combined with TapToSelect or TapToTrigger, the LongPress instance should be created first because it needs a higher priority for the TouchEvent.TOUCH event so that it can disable the other events.

See also

feathers.events.FeathersEventType.LONG_PRESS
feathers.utils.touch.TapToTrigger
feathers.utils.touch.TapToSelect


Public Properties
 PropertyDefined By
  customHitTest : Function
In addition to a normal call to hitTest(), a custom function may impose additional rules that determine if the target should be long pressed.
LongPress
  isEnabled : Boolean
May be set to false to disable the triggered event temporarily until set back to true.
LongPress
  longPressDuration : Number
The duration, in seconds, of a long press.
LongPress
  tapToSelect : TapToSelect
If the target can be selected by tapping, the TapToSelect instance should be passed in so that it can be temporarily disabled when a long press is detected.
LongPress
  tapToTrigger : TapToTrigger
If the target can be triggered by tapping, the TapToTrigger instance should be passed in so that it can be temporarily disabled when a long press is detected.
LongPress
  target : DisplayObject
The target component that should dispatch FeathersEventType.LONG_PRESS when tapped.
LongPress
Public Methods
 MethodDefined By
  
LongPress(target:DisplayObject = null)
Constructor.
LongPress
Property Detail
customHitTestproperty
customHitTest:Function

In addition to a normal call to hitTest(), a custom function may impose additional rules that determine if the target should be long pressed. Called on TouchPhase.BEGAN.

The function must have the following signature:

function(localPosition:Point):Boolean;

The function should return true if the target should be long pressed, and false if it should not be long pressed.


Implementation
    public function get customHitTest():Function
    public function set customHitTest(value:Function):void
isEnabledproperty 
isEnabled:Boolean

May be set to false to disable the triggered event temporarily until set back to true.


Implementation
    public function get isEnabled():Boolean
    public function set isEnabled(value:Boolean):void
longPressDurationproperty 
longPressDuration:Number

The duration, in seconds, of a long press.

The following example changes the long press duration to one full second:

longPress.longPressDuration = 1.0;

The default value is 0.5.


Implementation
    public function get longPressDuration():Number
    public function set longPressDuration(value:Number):void
tapToSelectproperty 
tapToSelect:TapToSelect

If the target can be selected by tapping, the TapToSelect instance should be passed in so that it can be temporarily disabled when a long press is detected.


Implementation
    public function get tapToSelect():TapToSelect
    public function set tapToSelect(value:TapToSelect):void
tapToTriggerproperty 
tapToTrigger:TapToTrigger

If the target can be triggered by tapping, the TapToTrigger instance should be passed in so that it can be temporarily disabled when a long press is detected.


Implementation
    public function get tapToTrigger():TapToTrigger
    public function set tapToTrigger(value:TapToTrigger):void
targetproperty 
target:DisplayObject

The target component that should dispatch FeathersEventType.LONG_PRESS when tapped.


Implementation
    public function get target():DisplayObject
    public function set target(value:DisplayObject):void
Constructor Detail
LongPress()Constructor
public function LongPress(target:DisplayObject = null)

Constructor.

Parameters
target:DisplayObject (default = null)