WidgetGroup
WidgetGroup is a container which can add child widgets. Widget inherints from WidgetGroup can add child widgets as well.
INFO
We will add a WidgetGroup for all widget inherints from it.
Basic properties
All properties can be accessed via Java / KubeJS.
| Field | Description |
|---|---|
widgets | all child widgets |
layout | layout of child widgets |
layoutPadding | padding offset |
java
for (var child in group.widgets) {
}javascript
for (let child of group.widgets) {
}WARNING
DO NOT add widget to the group.widgets directly!! please check below methods.
APIs
addWidgets()
Add child widgets to it in order.
java
var button = ...;
var label = ...;
group.addWidgets(button, label);removeWidget() / clearAllWidgets()
Remove child widget from it.
java
var child = group.getFirstWidgetById("button_id");
group.removeWidget(child);
group.clearAllWidget();waitToAdded() / waitToRemoved()
Basically equals to the addWidgets() and removeWidget(). However, these two methods is useful for iteration and multi-thread. It handles widget in the next tick (in main thread).