Class TClickableWidget
java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.TElement
io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget
- All Implemented Interfaces:
TParentElement
,ITooltipProvider
,IEnableStateProvider
,IEnableStateProviderSetter
- Direct Known Subclasses:
TButtonWidget
,TTextFieldWidget
An abstract class representing a clickable widget that extends
TElement
.
A TClickableWidget
can be interacted with either by clicking it with the mouse or
by pressing the enter key when it is focused. This class provides methods to handle the
click action and to process input events.
Subclasses of TClickableWidget need to implement the onClick()
method to define
the behavior when the widget is clicked.
- See Also:
-
Nested Class Summary
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 TypeFieldDescriptionstatic final int
static final net.minecraft.client.gui.screen.ButtonTextures
Vanilla-game button textures.protected boolean
static final net.minecraft.util.Identifier
TCDCommons
's widget textures image.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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
click
(boolean playClickSound) Clicks thisTClickableWidget
.final boolean
Returns true if thisObject
is enabled.boolean
input
(TInputContext inputContext) An input handler that handles inputs on theTInputContext.InputDiscoveryPhase.MAIN
input phase.boolean
protected abstract void
onClick()
Called when thisTClickableWidget
is clicked, either by a mouse or a keyboard input, or byclick(boolean)
.void
setEnabled
(boolean enabled) Sets the "enabled" state for thisObject
.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, render, 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
-
BUTTON_TEXTURE_SLICE_SIZE
public static final int BUTTON_TEXTURE_SLICE_SIZE- See Also:
-
BUTTON_TEXTURES
public static final net.minecraft.client.gui.screen.ButtonTextures BUTTON_TEXTURESVanilla-game button textures. -
T_WIDGETS_TEXTURE
public static final net.minecraft.util.Identifier T_WIDGETS_TEXTURETCDCommons
's widget textures image. -
enabled
protected boolean enabled -
eClicked
-
-
Constructor Details
-
TClickableWidget
public TClickableWidget(int x, int y, int width, int height)
-
-
Method Details
-
isFocusable
public boolean isFocusable()- Overrides:
isFocusable
in classTElement
-
getEnabled
public final boolean getEnabled()Description copied from interface:IEnableStateProvider
Returns true if thisObject
is enabled.- Specified by:
getEnabled
in interfaceIEnableStateProvider
- Specified by:
getEnabled
in interfaceTParentElement
- Overrides:
getEnabled
in classTElement
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:IEnableStateProviderSetter
Sets the "enabled" state for thisObject
.- Specified by:
setEnabled
in interfaceIEnableStateProviderSetter
- Parameters:
enabled
- Whether or not thisObject
will be enabled.
-
click
public final void click(boolean playClickSound) Clicks thisTClickableWidget
.- Parameters:
playClickSound
- Whether or not to play the GUI button click sound.
-
onClick
protected abstract void onClick()Called when thisTClickableWidget
is clicked, either by a mouse or a keyboard input, or byclick(boolean)
. -
input
Description copied from interface:TParentElement
An input handler that handles inputs on theTInputContext.InputDiscoveryPhase.MAIN
input phase.- Specified by:
input
in interfaceTParentElement
- Overrides:
input
in classTElement
- Parameters:
inputContext
- TheTInputContext
containing information about a given input.- See Also:
-