Skip to content

TextTextureWidget

TextTextureWidget is an advanced text widget compared with LabelWidget. It wrapper an internal TextTexture, therefore, you can set the all text rendering properties by it.

Basic Properties

Field Description
lastComponent The last component text displayed read only
textTexture Internal TextTexture read only

APIs

textureStyle

Modifies the style of the internal text texture. see TextTexture for more details.

textTextureWidget.textureStyle(texture -> {
    texture.setType(TextType.ROLL);
    texture.setRollSpeed(0.5);
});
textTextureWidget.textureStyle(texture => {
    texture.setType(TextType.ROLL);
    texture.setRollSpeed(0.5);
});

setText

Sets the text using a string.

textTextureWidget.setText("Hello World");

setText / setComponent

Sets the text using a Component.

textTextureWidget.setText(Component.literal("Hello World"));
textTextureWidget.setComponent("....");

setText / setTextProvider

Sets the text using a Supplier.

textTextureWidget.setText(() -> "dynamic text");
textTextureWidget.setTextProvider(() => Component.string("dynamic text"));