public class WToggleButton extends WWidget
| Modifier and Type | Field and Description |
|---|---|
protected int |
color |
protected int |
darkmodeColor |
protected static Texture |
DEFAULT_FOCUS_IMAGE |
protected static Texture |
DEFAULT_OFF_IMAGE |
protected static Texture |
DEFAULT_ON_IMAGE |
protected Texture |
focusImage |
protected boolean |
isOn |
protected @Nullable net.minecraft.text.Text |
label |
protected Texture |
offImage |
protected Texture |
onImage |
protected @Nullable java.util.function.Consumer<java.lang.Boolean> |
onToggle |
| Constructor and Description |
|---|
WToggleButton()
Constructs a toggle button with default images and no label.
|
WToggleButton(net.minecraft.util.Identifier onImage,
net.minecraft.util.Identifier offImage)
Constructs a toggle button with custom images and no label.
|
WToggleButton(net.minecraft.util.Identifier onImage,
net.minecraft.util.Identifier offImage,
net.minecraft.text.Text label)
Constructs a toggle button with custom images.
|
WToggleButton(net.minecraft.text.Text label)
Constructs a toggle button with default images.
|
WToggleButton(Texture onImage,
Texture offImage)
Constructs a toggle button with custom images and no label.
|
WToggleButton(Texture onImage,
Texture offImage,
net.minecraft.text.Text label)
Constructs a toggle button with custom images.
|
| 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). |
Texture |
getFocusImage() |
@Nullable net.minecraft.text.Text |
getLabel() |
Texture |
getOffImage() |
Texture |
getOnImage() |
@Nullable java.util.function.Consumer<java.lang.Boolean> |
getOnToggle() |
boolean |
getToggle() |
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.
|
protected void |
onToggle(boolean on) |
void |
paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
Paints this widget.
|
WToggleButton |
setColor(int light,
int dark) |
WToggleButton |
setFocusImage(Texture focusImage) |
WToggleButton |
setLabel(@Nullable net.minecraft.text.Text label) |
WToggleButton |
setOffImage(Texture offImage) |
WToggleButton |
setOnImage(Texture onImage) |
WToggleButton |
setOnToggle(@Nullable java.util.function.Consumer<java.lang.Boolean> onToggle) |
void |
setToggle(boolean on) |
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, setSize, tick, validateprotected static final Texture DEFAULT_OFF_IMAGE
protected static final Texture DEFAULT_ON_IMAGE
protected static final Texture DEFAULT_FOCUS_IMAGE
protected Texture onImage
protected Texture offImage
protected Texture focusImage
@Nullable protected @Nullable net.minecraft.text.Text label
protected boolean isOn
@Nullable protected @Nullable java.util.function.Consumer<java.lang.Boolean> onToggle
protected int color
protected int darkmodeColor
public WToggleButton()
public WToggleButton(net.minecraft.text.Text label)
label - the button labelpublic WToggleButton(net.minecraft.util.Identifier onImage,
net.minecraft.util.Identifier offImage)
onImage - the toggled on imageoffImage - the toggled off imagepublic WToggleButton(net.minecraft.util.Identifier onImage,
net.minecraft.util.Identifier offImage,
net.minecraft.text.Text label)
onImage - the toggled on imageoffImage - the toggled off imagelabel - the button labelpublic WToggleButton(Texture onImage, Texture offImage)
onImage - the toggled on imageoffImage - the toggled off image@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidgetpublic boolean canResize()
WWidgetWWidget.setSize(int, int).public boolean canFocus()
WWidget@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.public void onKeyPressed(int ch,
int key,
int modifiers)
WWidgetonKeyPressed in class WWidgetkey - the GLFW scancode of the keyprotected void onToggle(boolean on)
public boolean getToggle()
public void setToggle(boolean on)
@Nullable public @Nullable java.util.function.Consumer<java.lang.Boolean> getOnToggle()
public WToggleButton setOnToggle(@Nullable @Nullable java.util.function.Consumer<java.lang.Boolean> onToggle)
@Nullable public @Nullable net.minecraft.text.Text getLabel()
public WToggleButton setLabel(@Nullable @Nullable net.minecraft.text.Text label)
public WToggleButton setColor(int light, int dark)
public Texture getOnImage()
public WToggleButton setOnImage(Texture onImage)
public Texture getOffImage()
public WToggleButton setOffImage(Texture offImage)
public Texture getFocusImage()
public WToggleButton setFocusImage(Texture focusImage)