Class TButtonWidget
java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.TElement
io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget
io.github.thecsdev.tcdcommons.api.client.gui.widget.TButtonWidget
- All Implemented Interfaces:
TParentElement
,ITooltipProvider
,IEnableStateProvider
,IEnableStateProviderSetter
,ITextProvider
,ITextProviderSetter
- Direct Known Subclasses:
FileListItem
,TCheckboxWidget
,TitleBar.TitleBarSquareButton
,TMenuPanelButton
,TSelectWidget
,TSliderWidget
A
TButtonWidget
is a TClickableWidget
that
looks and behaves like a vanilla button.-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget
TClickableWidget.TClickableWidgetEvent_Clicked
Nested classes/interfaces inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
TElement.TElementEvent_ChildAR, TElement.TElementEvent_ContextMenu, TElement.TElementEvent_Moved, TElement.TElementEvent_ParentChanged, TElement.TElementEvent_Resized
-
Field Summary
Modifier and TypeFieldDescriptionprotected @Nullable UITexture
protected final float[]
protected @Nullable Consumer
<TButtonWidget> protected @Nullable net.minecraft.text.Text
Fields inherited from class io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget
BUTTON_TEXTURE_SLICE_SIZE, BUTTON_TEXTURES, eClicked, enabled, T_WIDGETS_TEXTURE
Fields inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
alpha, eChildAdded, eChildRemoved, eContextMenu, eMoved, eParentChanged, eResized, height, SP_ALL, SP_INVOKE_EVENT, SP_MOVE_CHILDREN, SP_RELATIVE, SP_UPDATE_TOPMOST, SS_ALL, SS_INVOKE_EVENT, SS_UPDATE_TOPMOST, tooltip, tooltipPositioner, width, x, y, zOffset
Fields inherited from interface io.github.thecsdev.tcdcommons.api.client.gui.TParentElement
MAX_CHILD_NESTING_DEPTH
-
Constructor Summary
ConstructorDescriptionTButtonWidget
(int x, int y, int width, int height) TButtonWidget
(int x, int y, int width, int height, net.minecraft.text.Text text) TButtonWidget
(int x, int y, int width, int height, net.minecraft.text.Text text, Consumer<TButtonWidget> onClick) -
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable UITexture
getIcon()
final float[]
final @Nullable Consumer
<TButtonWidget> final @Nullable net.minecraft.text.Text
getText()
protected void
onClick()
Called when thisTClickableWidget
is clicked, either by a mouse or a keyboard input, or byTClickableWidget.click(boolean)
.void
render
(TDrawContext pencil) Renders this GUI element on the screen.protected void
renderBackground
(TDrawContext pencil) By default, renders the "background" texture and icon for thisTButtonWidget
.protected void
renderIcon
(TDrawContext pencil) By default, renders the "background" icon for thisTButtonWidget
.void
final void
setIconColor
(float r, float g, float b) void
setIconColor
(float r, float g, float b, float a) void
setOnClick
(@Nullable Consumer<TButtonWidget> onClick) void
setText
(@Nullable net.minecraft.text.Text text) Methods inherited from class io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget
click, getEnabled, input, isFocusable, setEnabled
Methods inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
canBeAddedTo, createContextMenu, getAlpha, getChildren, getHeight, getItemRenderer, getParent, getParentTElement, getParentTScreen, getTextRenderer, getTooltip, getTooltipPositioner, getWidth, getX, getY, getZIndex, getZOffset, isDragging, isEnabled, isEnabledAndVisible, isFocused, isFocusedOrHovered, isHoverable, isHovered, isVisible, move, moveChildren, next, postRender, previous, setAlpha, setPosition, setPosition, setSize, setSize, setTooltip, setZOffset, tick, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.thecsdev.tcdcommons.api.client.gui.TParentElement
addChild, addChild, clearChildren, findChild, findLastChild, findParent, findParentTElement, forEachChild, getEndX, getEndY, input, removeChild, removeChild
-
Field Details
-
text
@Nullable protected @Nullable net.minecraft.text.Text text -
onClick
-
icon
-
iconColor
protected final float[] iconColor
-
-
Constructor Details
-
TButtonWidget
public TButtonWidget(int x, int y, int width, int height) -
TButtonWidget
public TButtonWidget(int x, int y, int width, int height, net.minecraft.text.Text text) -
TButtonWidget
public TButtonWidget(int x, int y, int width, int height, net.minecraft.text.Text text, Consumer<TButtonWidget> onClick)
-
-
Method Details
-
getText
@Nullable public final @Nullable net.minecraft.text.Text getText()- Specified by:
getText
in interfaceITextProvider
-
setText
public void setText(@Nullable @Nullable net.minecraft.text.Text text) - Specified by:
setText
in interfaceITextProviderSetter
-
getOnClick
-
setOnClick
-
getIcon
-
setIcon
-
getIconColor
public final float[] getIconColor() -
setIconColor
public final void setIconColor(float r, float g, float b) -
setIconColor
public void setIconColor(float r, float g, float b, float a) -
onClick
protected void onClick()Description copied from class:TClickableWidget
Called when thisTClickableWidget
is clicked, either by a mouse or a keyboard input, or byTClickableWidget.click(boolean)
.- Specified by:
onClick
in classTClickableWidget
-
render
Description copied from interface:TParentElement
Renders this GUI element on the screen.- Specified by:
render
in interfaceTParentElement
- Specified by:
render
in classTElement
- Parameters:
pencil
- TheTDrawContext
.
-
renderBackground
By default, renders the "background" texture and icon for thisTButtonWidget
.- Parameters:
pencil
- TheTDrawContext
.
-
renderIcon
By default, renders the "background" icon for thisTButtonWidget
.- Parameters:
pencil
- TheTDrawContext
.
-