Skip to content

WidgetGroup

WidgetGroup

WidgetGroup is a container which can add child widgets. Widget inherints from WidgetGroup can add child widgets as well.

Note

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
for (var child in group.widgets) {

}
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.

var button = ...;
var label = ...;
group.addWidgets(button, label);

removeWidget() / clearAllWidgets()

Remove child widget from it.

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).