How to dispatch a long press event from a custom item renderer (AS3/Starling version)
A custom item renderer may optionally dispatch FeathersEventType.LONG_PRESS, similar to a Button.
Using the LongPress class, it's easy to dispatch FeathersEventType.LONG_PRESS:
public class CustomItemRenderer extends LayoutGroupListItemRenderer
{
public function CustomItemRenderer()
{
super();
this._longPress = new LongPress(this);
}
private var _longPress:LongPress;
}
That's it! The TouchEvent.TOUCH listeners will be added automatically, and your item renderer will dispatch FeathersEventType.LONG_PRESS like a button.
Combined with Event.TRIGGERED or Event.CHANGE
If you plan to combine, LongPress with TapToTrigger or TapToSelect, you should ensure that the other two events aren't dispatched after a long press.
First, always create the LongPress instance before the TapToTrigger and TapToSelect instances. This ensures that the TouchEvent.TOUCH listener in LongPress gets a higher priority.
this._longPress = new LongPress(this);
this._trigger = new TapToTrigger(this);
this._select = new TapToSelect(this);
Then, pass the TapToTrigger and TapToSelect instances to the LongPress so that it can disable them temporarily after a long press.
this._longPress.tapToTrigger = this._trigger;
this._longPress.tapToSelect = this._select;