@Environment(value=CLIENT) public abstract class AbstractButtonWidget extends DrawableHelper implements Drawable, Element
Modifier and Type | Field and Description |
---|---|
boolean |
active |
protected float |
alpha |
private boolean |
focused |
protected int |
height |
protected boolean |
hovered |
private Text |
message |
protected long |
nextNarration |
boolean |
visible |
private boolean |
wasHovered |
static Identifier |
WIDGETS_LOCATION |
protected int |
width |
int |
x |
int |
y |
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE
Constructor and Description |
---|
AbstractButtonWidget(int x,
int y,
int width,
int height,
Text message) |
Modifier and Type | Method and Description |
---|---|
boolean |
changeFocus(boolean lookForwards)
Changes the focusing element by cycling to the next/previous element.
|
protected boolean |
clicked(double mouseX,
double mouseY) |
int |
getHeight() |
Text |
getMessage() |
protected MutableText |
getNarrationMessage() |
int |
getWidth() |
protected int |
getYImage(boolean hovered) |
boolean |
isFocused() |
boolean |
isHovered() |
boolean |
isMouseOver(double mouseX,
double mouseY)
Checks if the mouse position is within the bound
of the element.
|
protected boolean |
isValidClickButton(int button) |
boolean |
mouseClicked(double mouseX,
double mouseY,
int button)
Callback for when a mouse button down event
has been captured.
|
boolean |
mouseDragged(double mouseX,
double mouseY,
int button,
double deltaX,
double deltaY)
Callback for when a mouse button drag event
has been captured.
|
boolean |
mouseReleased(double mouseX,
double mouseY,
int button)
Callback for when a mouse button release event
has been captured.
|
protected void |
narrate() |
void |
onClick(double mouseX,
double mouseY) |
protected void |
onDrag(double mouseX,
double mouseY,
double deltaX,
double deltaY) |
protected void |
onFocusedChanged(boolean bool) |
void |
onRelease(double mouseX,
double mouseY) |
void |
playDownSound(SoundManager soundManager) |
void |
queueNarration(int delay) |
void |
render(MatrixStack matrices,
int mouseX,
int mouseY,
float delta) |
protected void |
renderBg(MatrixStack matrices,
MinecraftClient client,
int mouseX,
int mouseY) |
void |
renderButton(MatrixStack matrices,
int mouseX,
int mouseY,
float delta) |
void |
renderToolTip(MatrixStack matrices,
int mouseX,
int mouseY) |
void |
setAlpha(float value) |
protected void |
setFocused(boolean focused) |
void |
setMessage(Text text) |
void |
setWidth(int value) |
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, setZOffset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
charTyped, keyPressed, keyReleased, mouseMoved, mouseScrolled
public static final Identifier WIDGETS_LOCATION
protected int width
protected int height
public int x
public int y
private Text message
private boolean wasHovered
protected boolean hovered
public boolean active
public boolean visible
protected float alpha
protected long nextNarration
private boolean focused
public AbstractButtonWidget(int x, int y, int width, int height, Text message)
public int getHeight()
protected int getYImage(boolean hovered)
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
protected void narrate()
protected MutableText getNarrationMessage()
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta)
protected void renderBg(MatrixStack matrices, MinecraftClient client, int mouseX, int mouseY)
public void onClick(double mouseX, double mouseY)
public void onRelease(double mouseX, double mouseY)
protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY)
public boolean mouseClicked(double mouseX, double mouseY, int button)
GLFW
class.mouseClicked
in interface Element
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousebutton
- the mouse button numbertrue
to indicate that the event handling is successful/validMouse.onMouseButton(long, int, int, int)
,
GLFW.GLFW_MOUSE_BUTTON_1
public boolean mouseReleased(double mouseX, double mouseY, int button)
GLFW
class.mouseReleased
in interface Element
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousebutton
- the mouse button numbertrue
to indicate that the event handling is successful/validMouse.onMouseButton(long, int, int, int)
,
GLFW.GLFW_MOUSE_BUTTON_1
protected boolean isValidClickButton(int button)
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
GLFW
class.mouseDragged
in interface Element
mouseX
- the current X coordinate of the mousemouseY
- the current Y coordinate of the mousebutton
- the mouse button numberdeltaX
- the difference of the current X with the previous X coordinatedeltaY
- the difference of the current Y with the previous Y coordinatetrue
to indicate that the event handling is successful/validMouse.onCursorPos(long, double, double)
,
GLFW.GLFW_MOUSE_BUTTON_1
protected boolean clicked(double mouseX, double mouseY)
public boolean isHovered()
public boolean changeFocus(boolean lookForwards)
changeFocus
in interface Element
lookForwards
- true
to cycle forwards, otherwise cycle backwardstrue
to indicate that the event handling is successful/validprotected void onFocusedChanged(boolean bool)
public boolean isMouseOver(double mouseX, double mouseY)
isMouseOver
in interface Element
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousetrue
if the mouse is within the bound of the element, otherwise false
public void renderToolTip(MatrixStack matrices, int mouseX, int mouseY)
public void playDownSound(SoundManager soundManager)
public int getWidth()
public void setWidth(int value)
public void setAlpha(float value)
public void setMessage(Text text)
public void queueNarration(int delay)
public Text getMessage()
public boolean isFocused()
protected void setFocused(boolean focused)