Changes a target's state based on pointer events (MouseEvent and TouchEvent), like a button.

Available since

1.0.0

.

See also:

Constructor

@:value({ callback : null, target : null })new(?target:InteractiveObject, ?callback:T ‑> Void, upState:T, downState:T, hoverState:T)

Creates a new PointerToState object with the given arguments.

Available since

1.0.0

.

Variables

read onlycurrentState:T

The current state of the utility. May be different than the state of the target.

Available since

1.0.0

.

downState:T

The value for the "down" state.

Available since

1.0.0

.

enabled:Bool

May be set to false to disable the state changes temporarily until set back to true.

Available since

1.0.0

.

hoverState:T

The value for the "hover" state.

Available since

1.0.0

.

keepDownStateOnRollOut:Bool

If true, the current state will remain as downState until MouseEvent.MOUSE_UP is dispatched. If false, and the pointer leaves the bounds of the target after MouseEvent.MOUSE_DOWN, the current state will change to upState.

Available since

1.0.0

.

stateContext:IStateContext<T>

An optional IStateContext that may be used instead of target.

Available since

1.0.0

.

target:InteractiveObject

The target component that should change state based on pointer (mouse or touch) events.

Available since

1.0.0

.

upState:T

The value for the "up" state.

Available since

1.0.0

.

callback:T ‑> Void

The function to call when the state is changed.

The callback is expected to have the following signature:

String -> Void
Available since

1.0.0

.

customHitTest:(stageX:Float, stageY:Float) ‑> Bool

In addition to the normal hit testing for mouse/touch events, a custom function may impose additional rules that determine if the target should change state.

The function should return true if the target should change state, and false if it should not change state.

Available since

1.0.0

.