WidgetConfig
Adds a child widget to this widget. Removes any existing parent from the child first.
The child widget
The child widget
Calls the draw() method of this widget and all children widgets recursively. If a widget is disabled it will stop the cascade.
Sends a mouse event through a tree of Widgets. If any widget's onMouseClick returns true, the event will be captured and stop cascading.
Widgets are called in reverse order, so the last one to render will be the first one called for onMouseClick.
Calls update() for this widget and all children widgets recursively. Children added last will be called last. If a widget is disabled, the update will stop there.
Clears the function run on update.
The Widget
Draws on to the given terminal using the widget's current state. Will not draw if disabled.
Returns a Vector2 relative to true 0,0, which is usually the top left of the terminal.
Gets the local origin. This will be relative to the parent's origin.
Gets the current state of the widget. While not a copy, it's recommended to use setState rather than mutate this object.
Whether or not the widget will update/draw
boolean
Calls onMouseClick if the widget is not disabled
MouseHanderEvent
Will be fired on click() or cascadeClick(). Return 'true' to capture the event, which will make it no longer cascade to other widgets. Return 'false' to pass the event to other widgets.
boolean - Capture the event
Removes a child widget from the parent widget. Clears inherited Terminal/MouseHandler/KeyboardHandler
The child widget
The child widget if found, undefined otherwise.
Sets the disabled state.
Default true
Sets the mouseHandler for this widget and all children widgets. Will be passed to any children added in the future as well.
Leave empty to clear
this
Sets the local origin of the widget relative to it's parent, then updates the absoluteOrigin of the widget
Vector2 - The position relative to its parent
Adds the widget to a parent.
this - The child widget
Sets the state of the widget. Partial values allowed.
Partial
Sets the terminal for this widget and all children widgets. Will be passed to any children added in the future as well.
Leave empty to clear
this
Set a function to run whenever update or cascadeUpdate is called. Generally this is used with closures/currying to transform game state to function state.
The function called on update
The widget
Calls an updateFunc if previously given, and merges it into the widgets state.
Generated using TypeDoc
Creates a new Widget.