public class WButton extends WWidget
| Modifier and Type | Field and Description |
|---|---|
protected HorizontalAlignment |
alignment |
protected int |
color |
protected int |
darkmodeColor |
| Constructor and Description |
|---|
WButton()
Constructs a button with no label and no icon.
|
WButton(Icon icon)
Constructs a button with an icon.
|
WButton(Icon icon,
net.minecraft.text.Text label)
Constructs a button with an icon and a label.
|
WButton(net.minecraft.text.Text label)
Constructs a button with a label.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canFocus()
Tests whether this widget can have the focus in the GUI.
|
boolean |
canResize()
Checks whether this widget can be resized using
WWidget.setSize(int, int). |
HorizontalAlignment |
getAlignment() |
@Nullable Icon |
getIcon()
Gets the icon of this button.
|
net.minecraft.text.Text |
getLabel() |
@Nullable java.lang.Runnable |
getOnClick()
Gets the click handler of this button.
|
boolean |
isEnabled() |
InputResult |
onClick(int x,
int y,
int button)
Notifies this widget that the mouse has been pressed and released, both while inside its bounds.
|
void |
onKeyPressed(int ch,
int key,
int modifiers)
Notifies this widget that a key has been pressed.
|
void |
paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
Paints this widget.
|
WButton |
setAlignment(HorizontalAlignment alignment) |
WButton |
setEnabled(boolean enabled) |
WButton |
setIcon(@Nullable Icon icon)
Sets the icon of this button.
|
WButton |
setLabel(net.minecraft.text.Text label) |
WButton |
setOnClick(@Nullable java.lang.Runnable onClick)
Sets the click handler of this button.
|
void |
setSize(int x,
int y)
Sets the size of this widget.
|
addPainters, addTooltip, createPeers, cycleFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hit, isActivationKey, isFocused, isWithinBounds, onCharTyped, onFocusGained, onFocusLost, onHidden, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, tick, validateprotected int color
protected int darkmodeColor
protected HorizontalAlignment alignment
public WButton()
public WButton(Icon icon)
icon - the iconpublic WButton(net.minecraft.text.Text label)
label - the labelpublic WButton(Icon icon, net.minecraft.text.Text label)
icon - the iconlabel - the labelpublic boolean canResize()
WWidgetWWidget.setSize(int, int).public boolean canFocus()
WWidget@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidgetpublic void setSize(int x,
int y)
WWidgetOverriding methods may restrict one of the dimensions to be
a constant value, for example super.setSize(x, 20).
@Environment(value=CLIENT) public InputResult onClick(int x, int y, int button)
WWidgetonClick in class WWidgetx - The X coordinate of the event, in widget-space (0 is the left edge of this widget)y - The Y coordinate of the event, in widget-space (0 is the top edge of this widget)button - The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.@Environment(value=CLIENT)
public void onKeyPressed(int ch,
int key,
int modifiers)
WWidgetonKeyPressed in class WWidgetkey - the GLFW scancode of the key@Nullable public @Nullable java.lang.Runnable getOnClick()
public WButton setOnClick(@Nullable @Nullable java.lang.Runnable onClick)
onClick - the new click handlerpublic boolean isEnabled()
public WButton setEnabled(boolean enabled)
public net.minecraft.text.Text getLabel()
public WButton setLabel(net.minecraft.text.Text label)
public HorizontalAlignment getAlignment()
public WButton setAlignment(HorizontalAlignment alignment)
@Nullable public @Nullable Icon getIcon()