ButtonWidget

The ButtonWidget is a UI widget representing a clickable button in the GUI system
Basic properties
All properties can be accessed via Java / KubeJS.
| Field | Description |
|---|---|
isClicked | is the button clicked currently |
APIs
setButtonTexture()
Equal to the setBackground.
java
button.setButtonTexture(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("Button"));setClickedTexture()
Remove child widget from it.
java
button.setClickedTexture(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("Clicked"));setOnPressCallback()
Used to bind functional logic.
ClickData provides mouse state information:
clickData.button: mouse button id number.button Description 0left button 1right button 2middle button clickData.isShiftClick: is the shift key typed.clickData.isCtrlClick: is the ctrl key typed.clickData.isRemote: is the remote enverionment.
java
button.setOnPressCallback(clickData -> {
if (clickData.isRemote) { // can be used to check trigger side
}
});javascript
button.setOnPressCallback(clickData => {
if (clickData.isRemote) { // can be used to check trigger side
}
});