import DisplayObject from "../display/DisplayObject"; import Point from "openfl/geom/Point"; declare namespace starling.utils { /** * A utility class that can help with creating button-like display objects. * * * *
When reacting to touch input, taps can easily be recognized through standard touch
* * events via TouchPhase.ENDED. However, you often want a more elaborate kind of
* * input handling, like that provide by Starling's Button class and its
* * TRIGGERED event. It allows users to cancel a tap by moving the finger away from
* * the object, for example; and it supports changing its appearance depending on its state.
Here is an example: a class that extends TextField and uses * * ButtonBehavior to add TRIGGER events and state-based coloring.
* * * *Instances of this class will now dispatch Event.TRIGGERED events (just like * * conventional buttons) and they will change their color when being touched.
* */ export class ButtonBehavior { /** * Create a new ButtonBehavior. * * * * @param target The object on which to listen for touch events. * * @param onStateChange This callback will be executed whenever the button's state ought * * to change.function(state:String):void
* * @param minHitAreaSize If the display area of 'target' is smaller than a square of this
* * size, its hit area will be extended accordingly.
* * @param abortDistance The distance you can move away your finger before triggering
* * is aborted.
*
*/
constructor(target: DisplayObject, onStateChange: Function, minHitAreaSize?: number, abortDistance?: number);
/**
* Forward your target's hitTests to this method to make sure that the hit
* * area is extended to minHitAreaSize.
*/
hitTest(localPoint: Point): DisplayObject;
/**
* The current state of the button. The corresponding strings are found
* * in the ButtonState class.
*/
get state(): string;
set state(value: string)
/**
* The target on which this behavior operates.
*/
get target(): DisplayObject;
get_target(): DisplayObject;
/**
* The callback that is executed whenever the state changes.
* * Format: function(state:String):void
*
*/
get onStateChange(): Function;
set onStateChange(value: Function)
get_onStateChange(): Function;
set_onStateChange(value: Function): Function;
/**
* Indicates if the mouse cursor should transform into a hand while it's over the button.
* * @default true
*/
get useHandCursor(): boolean;
set useHandCursor(value: boolean)
get_useHandCursor(): boolean;
set_useHandCursor(value: boolean): boolean;
/**
* Indicates if the button can be triggered.
*/
get enabled(): boolean;
set enabled(value: boolean)
get_enabled(): boolean;
set_enabled(value: boolean): boolean;
/**
* The target's hit area will be extended to have at least this width / height.
* * Note that for this to work, you need to forward your hit tests to this class.
*/
get minHitAreaSize(): number;
set minHitAreaSize(value: number)
get_minHitAreaSize(): number;
set_minHitAreaSize(value: number): number;
/**
* The distance you can move away your finger before triggering is aborted.
*/
get abortDistance(): number;
set abortDistance(value: number)
get_abortDistance(): number;
set_abortDistance(value: number): number;
}
}
export default starling.utils.ButtonBehavior;