Skip to content

Preliminary

LDLib provides a wide range of widgets. You can review their functionalities and APIs on their respective pages. In this section, we introduce the fundamental concepts that underlie all widgets, ensuring you have a solid understanding of their common principles.

All widgets inherit from the Widget class. As a result, they all share a set of universal APIs.


Basic properties

All properties can be accessed via Java / KubeJS.

java
var id = widget.getId();
var pos = widget.getPosition();
widget.setSize(10, 32);
widget.setSlefPosition(10, 10);
FieldDescription
idWidget id, it doesn't have to be unique,and can be empty.
selftPositionSelf position represents the relative local position in the parent widget
parentPositionParent widget's global position.
positionGlobal position in the window, which is computed by the self position and parent position.
sizeWidget size, this property affect the rect collid dection, e.g. hover, click, etc.
isVisibleWhether the widget is visible, only affect rendering, logic is still working.
isActiveWhether the widget logic is working.
alignalign position refer to the parent.
backgroundTexturebackground texture.
hoverTexturedarw texture while mouse hover.
overlayoverlay texture above the background texture.
parentparent widget.
alignalign position refer to the parent.

about position

Position is an important concept. Check the image below: Image title


APIs

setHoverTooltips()

Used to define the tooltips while the mouse hovered. It support both string and component as input.

java
widget.setHoverTooltips("this is a button");
// widget.setHoverTooltips("line 1", "line2");

Textures

LDLib provides massive different types of textures, choose what you want:). See GUI Textures to check supported textures.

setBackground()

Used to set the background texture of the widget.

setHoverTexture()

Used to set the hover texture of the widget.

java
widget.setBackground(new ResourceTexture("ldlib:textures/gui/icon.png"));

isMouseOverElement()

TO check whether the mouse over the widget.

java
widget.isMouseOverElement(mouseX, mouseY);

Released under the MIT License.