This class is used to create a custom control (widget) with That is showed in a
absolute position on the screen. It's a base class for all the controls (widgets).
Emits the following events:
"mouse": It carries the pure mouse event, but it fires only if the mouse is over the control.
"relativeMouse": It's like the "mouse" event, but it carries the relative mouse X and Y (relative to the control).
Emits the following events:
Param
Type
Description
id
string
The id of the popup.
visible
boolean
If the popup is visible. Default is false (make it appears using show()).
attributes
PhisicalValues
The phisical values of the control (x, y, width, height).
children
InPageWidgetBuilder
The content of the control.
Example
const widget1 = new InPageWidgetBuilder()
widget1.addRow({ text: "┌────────┐", color: "yellow", style: "bold" })
widget1.addRow({ text: "│ START! │", color: "yellow", style: "bold" })
widget1.addRow({ text: "└────────┘", color: "yellow", style: "bold" })
const button1 = new Control("btn1", false, { x: 30, y: 18, width: 10, height: 3 }, widget1)
button1.on("relativeMouse", (event) => {
// The relative mouse event is triggered with the mouse position relative to the widget
//console.log(`Mouse event: x: ${event.data.x}, y: ${event.data.y}`)
if (event.name === "MOUSE_LEFT_BUTTON_RELEASED") {
GUI.log("Button 1 clicked!")
if (valueEmitter) {
clearInterval(valueEmitter)
valueEmitter = null
} else {
valueEmitter = setInterval(frame, period)
}
}
})
button1.show()
ADDED IN PAGE WIDGET
And cleaned code
Control ⇐
EventEmitter
Kind: global class
Extends:
EventEmitter
EventEmitter
Control
Control
Control
Control
boolean
boolean
Control
Control
void
Control
new Control(id, visible, attributes, children)
This class is used to create a custom control (widget) with That is showed in a absolute position on the screen. It's a base class for all the controls (widgets).
Emits the following events:
Emits the following events:
string
The id of the popup.
boolean
If the popup is visible. Default is false (make it appears using show()).
PhisicalValues
The phisical values of the control (x, y, width, height).
InPageWidgetBuilder
The content of the control.
Example