Creates a new Button instance.
The label text to display on the button
Configuration options for button appearance
OptionaldestroyedIndicates whether the element is currently being dragged
Indicates whether the mouse/pointer is currently over this element
Maximum time in milliseconds for a gesture to be considered a swipe
Minimum distance in pixels for a gesture to be considered a swipe
StaticrecomputeWhen true (default), each window-level dragmove recomputes the canvas rect
and renderer scale via getBoundingClientRect(). This makes drags survive
mid-drag canvas resizes, DPR/monitor changes, and CSS-zoom animations
without the cursor and element drifting apart.
Set to false to skip the per-move rect lookup (cache scale once at dragstart).
Saves a couple getBoundingClientRect() calls per pointermove — measurable
only at very high move rates or with thousands of concurrent draggables.
Sets the button label text.
New text to display
Adds an element to the internal elements array.
The element to add
Centers this element both horizontally and vertically within its parent container.
Centers this element horizontally within its parent container.
Centers this element vertically within its parent container.
OptionalskipUpdate: booleanOptionalpoint: PointOptionalskipUpdate: booleanOptionalrect: RectangleOptionalfn: EventListenerOptionalcontext: unknownOptionalcontext: unknownOptionalcontext: unknownRegisters a handler for drag start events.
Optionalhold: numberOptional time in milliseconds the pointer must be held before triggering drag
Registers a handler that fires after the element has been held down for a specified duration.
Registers a handler for pointer down (mouse down / touch start) events.
Registers a handler for pointer out (mouse leave) events.
Registers a handler for pointer over (mouse enter) events.
Registers a handler for pointer up (mouse up / touch end) events.
Registers a handler for swipe gestures in any direction.
Callback function to execute on swipe, receives swipe power as parameter
Forces a complete redraw of the button including background and text.
Redraws just the text portion of the button.
Optionalevent: stringOptionalbeginIndex: numberOptionalendIndex: numberRemoves an element from the internal elements array.
The element to remove
Optionalfn: EventListenerOptionalpoint: PointOptionalfrom: DisplayObjectOptionalpoint: PointUpdates the button's style options and triggers a redraw.
New style configuration to apply
Interactive button component with customizable appearance for different states. Supports bitmap fonts and regular text, backgrounds with colors or textures, and automatic state management for hover and pressed interactions.
Example