Class TClickableWidget
java.lang.Object
com.thecsdev.common.scene.Node<TElement>
com.thecsdev.commonmc.api.client.gui.TElement
com.thecsdev.commonmc.api.client.gui.widget.TClickableWidget
- All Implemented Interfaces:
INode<TElement>, INodeBounded<TElement,Bounds2i>, INodeRenderable<TElement, TGuiGraphics>, Iterable<TElement>, Collection<TElement>
- Direct Known Subclasses:
TButtonWidget, TCheckboxWidget, TSimpleTextFieldWidget
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Event<Consumer<TClickableWidget>> AnEventthat is invoked whenever thisTClickableWidgetis clicked.protected static final Consumer<TClickableWidget> Default event handler that plays a GUI click sound whenever thisTClickableWidgetis clicked.Fields inherited from class TElement
eInitialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclick()CallsclickCallback()and invokes theeClickedevent.protected voidCallback method that is invoked whenever thisTClickableWidgetis clicked.protected voidA callback method that is invoked whenever thisTElementstops being dragged.protected voidA callback method that is invoked whenever thisTElementstarts being dragged.final BooleanPropertyReturns aBooleanPropertythat holds aBooleanvalue representing the "enabled" state of thisTClickableWidget.protected voidA callback method that is invoked whenever thisTElementloses focus.@NotNull CursorTypeReturnsCursorTypethat represents the visual look the user's mouse cursor should have when thisTElementis hovered.protected voidA callback method that is invoked whenever thisTElementbecomes hovered.booleaninputCallback(@NotNull TInputContext.InputDiscoveryPhase phase, @NotNull TInputContext context) A callback method that is invoked when the user makes an input.booleanReturnstrueif thisTElementshould be receiving focus via user input such as mouse and keyboard.voidpostRenderCallback(@NotNull TGuiGraphics pencil) Callback method that is invoked after thisNodeand all of their children have been rendered.final BooleanPropertyReturns aBooleanPropertythat holds aBooleanvalue representing whether thisTClickableWidgetis currently being pressed.Methods inherited from class TElement
addRel, boundsProperty, clearAndInit, clipsDescendantsProperty, contextMenuProperty, findElementAt, focusableProperty, focusGainedCallback, forEachVisible, getBaseType, getBounds, getClient, getContentBounds, getSelf, getTooltip, hoverableProperty, hoverLostCallback, initCallback, invalidateTooltipCache, isFocused, isHoverable, isHovered, isHoveredOrFocused, isVisible, move, moveChildren, moveTo, removeRel, renderCallback, screenProperty, setBounds, setBounds, setBounds, showContextMenu, tickCallback, tooltipProperty, toString, visiblePropertyMethods inherited from class Node
add, addAll, childAddedCallback, childRemovedCallback, clear, contains, containsAll, equals, findChild, findParent, findSibling, forEach, get, getFirst, getLast, getParent, hashCode, indexOf, isEmpty, iterator, parentProperty, remove, remove, remove, removeAll, retainAll, rootProperty, size, toArray, toArray
-
Field Details
-
eClicked
AnEventthat is invoked whenever thisTClickableWidgetis clicked. Usually viaLMBor theEnterkey.The
Consumerprovides an instance ofthisfor convenience. -
ONCLICK_SOUND
Default event handler that plays a GUI click sound whenever thisTClickableWidgetis clicked. If you do not prefer this, you may remove this handler viaEvent.removeListener(Object).- See Also:
-
-
Constructor Details
-
TClickableWidget
public TClickableWidget()
-
-
Method Details
-
enabledProperty
Returns aBooleanPropertythat holds aBooleanvalue representing the "enabled" state of thisTClickableWidget. When "disabled", thisTClickableWidgetwill not handle click-related inputs. -
pressedProperty
Returns aBooleanPropertythat holds aBooleanvalue representing whether thisTClickableWidgetis currently being pressed. -
click
public final void click()CallsclickCallback()and invokes theeClickedevent. -
clickCallback
Callback method that is invoked whenever thisTClickableWidgetis clicked.- API Note:
- Remember to call
superwhen overriding this method!
-
getCursor
Description copied from class:TElementReturnsCursorTypethat represents the visual look the user's mouse cursor should have when thisTElementis hovered. -
isFocusable
Description copied from class:TElementReturnstrueif thisTElementshould be receiving focus via user input such as mouse and keyboard.- Overrides:
isFocusablein classTElement- See Also:
-
hoverGainedCallback
Description copied from class:TElementA callback method that is invoked whenever thisTElementbecomes hovered.- Overrides:
hoverGainedCallbackin classTElement- See Also:
-
dragStartCallback
Description copied from class:TElementA callback method that is invoked whenever thisTElementstarts being dragged.- Overrides:
dragStartCallbackin classTElement- See Also:
-
dragEndCallback
Description copied from class:TElementA callback method that is invoked whenever thisTElementstops being dragged.- Overrides:
dragEndCallbackin classTElement- See Also:
-
focusLostCallback
Description copied from class:TElementA callback method that is invoked whenever thisTElementloses focus.- Overrides:
focusLostCallbackin classTElement- See Also:
-
inputCallback
@Virtual public boolean inputCallback(@NotNull @NotNull TInputContext.InputDiscoveryPhase phase, @NotNull @NotNull TInputContext context) Description copied from class:TElementA callback method that is invoked when the user makes an input.- Overrides:
inputCallbackin classTElement- Parameters:
phase- The input discovery phase.context- Information about the user's input.- Returns:
trueif thisTElementhandled the input.
-
postRenderCallback
Description copied from interface:INodeRenderableCallback method that is invoked after thisNodeand all of their children have been rendered.- Specified by:
postRenderCallbackin interfaceINodeRenderable<TElement, TGuiGraphics>- Overrides:
postRenderCallbackin classTElement- Parameters:
pencil- The rendering context.
-