Package net.minecraft.client.gui.widget
Class AbstractButtonWidget
java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.widget.AbstractButtonWidget
- Direct Known Subclasses:
AbstractPressableButtonWidget,AnimatedResultButton,GameModeSelectionScreen.ButtonWidget,RecipeAlternativesWidget.AlternativeButtonWidget,SliderWidget,TextFieldWidget,ToggleButtonWidget
@Environment(CLIENT) public abstract class AbstractButtonWidget extends DrawableHelper implements Drawable, Element
-
Field Summary
Fields Modifier and Type Field Description booleanactiveprotected floatalphaprivate booleanfocusedprotected intheightprotected booleanhoveredprivate Textmessageprotected longnextNarrationbooleanvisibleprivate booleanwasHoveredstatic IdentifierWIDGETS_LOCATIONprotected intwidthintxintyFields inherited from class net.minecraft.client.gui.DrawableHelper
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE -
Constructor Summary
Constructors Constructor Description AbstractButtonWidget(int x, int y, int width, int height, Text message) -
Method Summary
Modifier and Type Method Description booleanchangeFocus(boolean lookForwards)Changes the focusing element by cycling to the next/previous element.protected booleanclicked(double mouseX, double mouseY)intgetHeight()TextgetMessage()protected MutableTextgetNarrationMessage()intgetWidth()protected intgetYImage(boolean hovered)booleanisFocused()booleanisHovered()booleanisMouseOver(double mouseX, double mouseY)Checks if the mouse position is within the bound of the element.protected booleanisValidClickButton(int button)static MutableTextmethod_32602(Text text)booleanmouseClicked(double mouseX, double mouseY, int button)Callback for when a mouse button down event has been captured.booleanmouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)Callback for when a mouse button drag event has been captured.booleanmouseReleased(double mouseX, double mouseY, int button)Callback for when a mouse button release event has been captured.protected voidnarrate()voidonClick(double mouseX, double mouseY)protected voidonDrag(double mouseX, double mouseY, double deltaX, double deltaY)protected voidonFocusedChanged(boolean bool)voidonRelease(double mouseX, double mouseY)voidplayDownSound(SoundManager soundManager)voidqueueNarration(int delay)voidrender(MatrixStack matrices, int mouseX, int mouseY, float delta)protected voidrenderBg(MatrixStack matrices, MinecraftClient client, int mouseX, int mouseY)voidrenderButton(MatrixStack matrices, int mouseX, int mouseY, float delta)voidrenderToolTip(MatrixStack matrices, int mouseX, int mouseY)voidsetAlpha(float value)protected voidsetFocused(boolean focused)voidsetMessage(Text text)voidsetWidth(int value)Methods inherited from class net.minecraft.client.gui.DrawableHelper
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, method_33284, setZOffsetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.Element
charTyped, keyPressed, keyReleased, mouseMoved, mouseScrolled
-
Field Details
-
WIDGETS_LOCATION
-
width
protected int width -
height
protected int height -
x
public int x -
y
public int y -
message
-
wasHovered
private boolean wasHovered -
hovered
protected boolean hovered -
active
public boolean active -
visible
public boolean visible -
alpha
protected float alpha -
nextNarration
protected long nextNarration -
focused
private boolean focused
-
-
Constructor Details
-
AbstractButtonWidget
-
-
Method Details
-
getHeight
public int getHeight() -
getYImage
protected int getYImage(boolean hovered) -
render
-
narrate
protected void narrate() -
getNarrationMessage
-
method_32602
-
renderButton
-
renderBg
-
onClick
public void onClick(double mouseX, double mouseY) -
onRelease
public void onRelease(double mouseX, double mouseY) -
onDrag
protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY) -
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button)Callback for when a mouse button down event has been captured. The button number is identified by the constants inGLFWclass.- Specified by:
mouseClickedin interfaceElement- Parameters:
mouseX- the X coordinate of the mousemouseY- the Y coordinate of the mousebutton- the mouse button number- Returns:
trueto indicate that the event handling is successful/valid- See Also:
Mouse.onMouseButton(long, int, int, int),GLFW.GLFW_MOUSE_BUTTON_1
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button)Callback for when a mouse button release event has been captured. The button number is identified by the constants inGLFWclass.- Specified by:
mouseReleasedin interfaceElement- Parameters:
mouseX- the X coordinate of the mousemouseY- the Y coordinate of the mousebutton- the mouse button number- Returns:
trueto indicate that the event handling is successful/valid- See Also:
Mouse.onMouseButton(long, int, int, int),GLFW.GLFW_MOUSE_BUTTON_1
-
isValidClickButton
protected boolean isValidClickButton(int button) -
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)Callback for when a mouse button drag event has been captured. The button number is identified by the constants inGLFWclass.- Specified by:
mouseDraggedin interfaceElement- Parameters:
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 coordinate- Returns:
trueto indicate that the event handling is successful/valid- See Also:
Mouse.onCursorPos(long, double, double),GLFW.GLFW_MOUSE_BUTTON_1
-
clicked
protected boolean clicked(double mouseX, double mouseY) -
isHovered
public boolean isHovered() -
changeFocus
public boolean changeFocus(boolean lookForwards)Changes the focusing element by cycling to the next/previous element. This action is done typically when the user has pressed the 'Tab' or 'Ctrl+Tab' key.- Specified by:
changeFocusin interfaceElement- Parameters:
lookForwards-trueto cycle forwards, otherwise cycle backwards- Returns:
trueto indicate that the event handling is successful/valid
-
onFocusedChanged
protected void onFocusedChanged(boolean bool) -
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY)Checks if the mouse position is within the bound of the element.- Specified by:
isMouseOverin interfaceElement- Parameters:
mouseX- the X coordinate of the mousemouseY- the Y coordinate of the mouse- Returns:
trueif the mouse is within the bound of the element, otherwisefalse
-
renderToolTip
-
playDownSound
-
getWidth
public int getWidth() -
setWidth
public void setWidth(int value) -
setAlpha
public void setAlpha(float value) -
setMessage
-
queueNarration
public void queueNarration(int delay) -
getMessage
-
isFocused
public boolean isFocused() -
setFocused
protected void setFocused(boolean focused)
-