The Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Gets the button's active state.
Sets the button's active state. If set to false, the button will be visible but will not respond to hover or touch interactions. Defaults to true.
Gets the enabled state of the component.
Sets the enabled state of the component.
Gets the duration to be used when fading between tints, in milliseconds.
Sets the duration to be used when fading between tints, in milliseconds. Defaults to 0.
Gets the frame to be used from the hover sprite.
Sets the frame to be used from the hover sprite.
Gets the entity to be used as the button background.
Sets the entity to be used as the button background. The entity must have an ElementComponent configured as an image element.
Gets the frame to be used from the inactive sprite.
Sets the frame to be used from the inactive sprite.
Gets the frame to be used from the pressed sprite.
Sets the frame to be used from the pressed sprite.
Gets the button transition mode.
Sets the button transition mode. This controls how the button responds when the user hovers over it/presses it. Can be:
Defaults to BUTTON_TRANSITION_MODE_TINT.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optionalarg1: anyFirst argument that is passed to the event handler.
Optionalarg2: anySecond argument that is passed to the event handler.
Optionalarg3: anyThird argument that is passed to the event handler.
Optionalarg4: anyFourth argument that is passed to the event handler.
Optionalarg5: anyFifth argument that is passed to the event handler.
Optionalarg6: anySixth argument that is passed to the event handler.
Optionalarg7: anySeventh argument that is passed to the event handler.
Optionalarg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optionalname: stringName of the event to unbind.
Optionalcallback: HandleEventCallbackFunction to be unbound.
Optionalscope: anyScope that was used as the this when the event is fired.
Self for chaining.
const handler = () => {};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optionalscope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optionalscope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
StaticEVENT_Fired when the mouse is pressed and released on the component or when a touch starts and ends on the component. The handler is passed a ElementMouseEvent or ElementTouchEvent.
StaticEVENT_Fired when the button changes state to be not hovered.
StaticEVENT_Fired when the button changes state to be hovered.
StaticEVENT_Fired when the mouse is pressed while the cursor is on the component. The handler is passed a ElementMouseEvent.
StaticEVENT_Fired when the mouse cursor enters the component. The handler is passed a ElementMouseEvent.
StaticEVENT_Fired when the mouse cursor leaves the component. The handler is passed a ElementMouseEvent.
StaticEVENT_Fired when the mouse is released while the cursor is on the component. The handler is passed a ElementMouseEvent.
StaticEVENT_Fired when the button changes state to be not pressed.
StaticEVENT_Fired when the button changes state to be pressed.
StaticEVENT_Fired when a xr select ends on the component. The handler is passed a ElementSelectEvent.
StaticEVENT_Fired when a xr select now hovering over the component. The handler is passed a ElementSelectEvent.
StaticEVENT_Fired when a xr select not hovering over the component. The handler is passed a ElementSelectEvent.
StaticEVENT_Fired when a xr select starts on the component. The handler is passed a ElementSelectEvent.
StaticEVENT_Fired when a touch is canceled on the component. The handler is passed a ElementTouchEvent.
StaticEVENT_Fired when a touch ends on the component. The handler is passed a ElementTouchEvent.
StaticEVENT_Fired when a touch leaves the component. The handler is passed a ElementTouchEvent.
StaticEVENT_Fired when a touch starts on the component. The handler is passed a ElementTouchEvent.
A ButtonComponent enables a group of entities to behave like a button, with different visual states for hover and press interactions.