Class: UIWidget
The `UIWidget` class represents a UI element base class with various properties and
methods for managing its behavior and appearance.
It contains methods to set focus, visibility, enabled flag, selected flag, position, animation and
capture action events.
- parent of: UIBubble, UIDescriptionList, UIDialog, UIInputKeyboard, UIInputSlider, UIMenu, UIMenuTextItem, UIMessage, UIPrint, UIPrompt, UISprite, UIText
Constructors
- new UIWidget(options): UIWidget
The constructor.
Methods
- animate(animation: string): void
The "animate" function trigger animation to the widget `node` HTMLElement.
- animation: The `animation` parameter is a string that represents the name of the
animation to be applied to the `node` HTMLElement.
- appendChild(child: HTMLElement): void
The "appendChild" function appends a given HTML element as a child to the widget node.
- child: The `child` parameter is an instance of the `HTMLElement` class. It
represents an HTML element that you want to append to the widget node.
- appendStyles(styles: string): void
The "appendStyles" function appends CSS styles to the `node` HTMLElement.
- styles: The `styles` parameter is a string that represents CSS styles that you want
to append to the `cssText` property of the `node` object.
- delete(): void
The "delete" function free all resources.
Warning: you need to call this method to free allocation for this object.
- focus(): void
The "focus" function adds `u-focused` class to the `node` HTMLElement.
It emits a 'E_FOCUSED' event and subscribes to input action event.
- getId(): string
- getNode(): HTMLDivElement
The "getNode" function returns the root `node` HTMLElement of the widget.
- getPosition(): vec2
The "getPosition" function returns the relative x and y coordinates of the widget `node` HTMLElement.
- getScreenPosition(): vec2
The "getScreenPosition" function returns the left and top coordinates of the widget `node` HTMLElement on
the screen.
- isEnabled(): boolean
The "isEnabled" function checks if widget is enabled or not.
- isFocused(): boolean
The "isFocused" function checks if widget is focused.
- isSelected(): boolean
The "isSelected" function checks if widget is selected or not.
- isVisible(): boolean
The "isVisible" function checks if the widget is visible.
- onAction(actionId: string): void
The "onAction" function is a virtual method that is called when input action event is emitted.
- actionId: The `actionId` parameter is a string that represents the identifier of the
action being performed.
- removeChild(index: number): void
The "removeChild" function removes a child element from the widget node.
- index: The index parameter is the position of the child element that you want to
remove from the widget node.
- setEnabled(enabled: boolean): void
The "setEnabled" function sets the enabled state flag.
It is just to expose a convenient option to the user, this flag has not effect on the UI manager.
Nota bene: toggle the `u-disabled` class on `node`.
- enabled: The `enabled` parameter is a boolean value that determines whether the
widget is enabled or disabled.
- setId(id: string): void
The "setId" function sets the id property.
- id: A string representing the unique identifier to be set.
- setPosition(x: number, y: number): void
The "setPosition" function sets the left and top position to the widget `node` HTMLElement.
Nota bene: works only if position is `absolute`.
- x: The horizontal position of the element on the page.
- y: The vertical position of the element on the page.
- setSelected(selected: boolean): void
The "setSelected" function sets the selected state flag.
It is just to expose a convenient option to the user, this flag has not effect on the UI manager.
Nota bene: toggle the `u-selected` class on `node`.
- selected: The `selected` parameter is a boolean value that indicates whether the
element should be selected or not.
- setVisible(visible: boolean): void
The "setVisible" function sets the visibility state.
Nota bene: toggle the `u-hidden` class on `node`.
- visible: The `visible` parameter is a boolean value that determines whether the
element should be visible or hidden. If `visible` is true, the element will be displayed, otherwise
it will be hidden.
- unfocus(): void
The "unfocus" function removes the `u-focused` class from the `node` HTMLElement.
It emits an 'E_UNFOCUSED' event and unsubscribes the inputManager from input action event.
- update(ts: number): void
The "update" function.
- ts: The `ts` parameter stands for "timestep".