Class Inputtable
-
- All Implemented Interfaces:
public abstract class Inputtable extends Component
Extensions to Component which allow it to send and receive events.
- Since:
1.6.0
-
-
Field Summary
Fields Modifier and Type Field Description private BooleanacceptsInputprivate BooleanisEnabledprivate ByteinputStateprivate final Booleanfocusedprivate final Booleanfocusableprivate Stringnameprivate final PolyUIpolyUIprivate final <Error class: unknown class>initializedprivate final <Error class: unknown class><Component>childrenprivate Component_parentprivate Componentparentprivate Alignalignmentprivate Floatxprivate Floatyprivate Vec2atprivate final Vec2screenAtprivate Floatwidthprivate Floatheightprivate Vec2sizeprivate final BooleansizeValidprivate final Vec2visibleSizeprivate Vec4paddingprivate BytelayoutFlagsprivate BooleanrawResizeprivate BooleanlayoutIgnoredprivate final BooleancreatedWithSetPositionprivate final BooleancreatedWithSetSizeprivate final Booleanpositionedprivate Booleanrendersprivate Booleanclippedprivate final <Error class: unknown class><ComponentOp>operationsprivate final <Error class: unknown class>isOperating
-
Constructor Summary
Constructors Constructor Description Inputtable(Vec2 at, Vec2 size, Align alignment, Boolean focusable)
-
Method Summary
Modifier and Type Method Description final BooleanacceptsInput()final UnitsetAcceptsInput(Boolean acceptsInput)BooleanisEnabled()Disabled flag for this component. UnitsetEnabled(Boolean isEnabled)Disabled flag for this component. final BytegetInputState()The current input state of this component. final UnitsetInputState(@Dispatches(event = "Mouse.Entered", when = "value > INPUT_NONE") @Dispatches(event = "Mouse.Exited", when = "value == INPUT_NONE") Byte inputState)final BooleanisFocused()focused flag for this component. final BooleanisFocusable()Booleansetup(PolyUI polyUI)give this a PolyUI reference. Booleanaccept(Event event)called when this component receives an event. final UnitclearHandlers()Clear all event handlers for this component. final <E extends Event, S extends Inputtable> Son(S $self, E event, Function2<S, E, Boolean> handler)final <E extends Event, S extends Inputtable> SaddEventhandler(S $self, E event, Function2<S, E, Unit> handler)final BooleanhasListenersFor(Class<out Event> event)returns trueif this component has any non-specific event handlers registered for it.final BooleanhasListenersFor(Event event)returns trueif this component has any specific event handlers registered for it.-
Methods inherited from class org.polyfrost.polyui.component.Component
addChild, addChild, addOperation, addOperation, at, calculateSize, clipChildren, contains, contains, createdWithSetPosition, createdWithSetSize, debugString, draw, extraToString, fixVisibleSize, get, get, get, getAlignment, getAt, getChildren, getHeight, getInitialized, getLayoutFlags, getName, getOperations, getPadding, getParent, getParentOrNull, getPolyUI, getRenders, getScreenAt, getSize, getVisibleSize, getWidth, getX, getY, intersects, isClipped, isInside, isLayoutIgnored, isOperating, isPositioned, isRawResize, isSizeValid, position, recalculate, remove, removeChild, removeChild, removeOperation, rescale, rescale0, rescaleToPolyUIInstance, set, set, setAlignment, setAt, setClipped, setHeight, setLayoutFlags, setLayoutIgnored, setName, setPadding, setParent, setRawResize, setRenders, setSize, setWidth, setX, setY, set_parent, size, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
acceptsInput
final Boolean acceptsInput()
-
setAcceptsInput
final Unit setAcceptsInput(Boolean acceptsInput)
-
isEnabled
Boolean isEnabled()
Disabled flag for this component. Dispatches the Event.Lifetime.Disabled and Event.Lifetime.Enabled events.
- Since:
0.21.4
-
setEnabled
Unit setEnabled(Boolean isEnabled)
Disabled flag for this component. Dispatches the Event.Lifetime.Disabled and Event.Lifetime.Enabled events.
- Since:
0.21.4
-
getInputState
final Byte getInputState()
The current input state of this component. Note that this value is not responsible for dispatching events such as Event.Mouse.Exited or Event.Mouse.Pressed. It is just here for tracking purposes and for your benefit.
This value will be of INPUT_NONE (0), INPUT_HOVERED (1), or INPUT_PRESSED (2).
Do not modify this value!
- Since:
1.0.0
-
setInputState
@ApiStatus.Internal() final Unit setInputState(@Dispatches(event = "Mouse.Entered", when = "value > INPUT_NONE") @Dispatches(event = "Mouse.Exited", when = "value == INPUT_NONE") Byte inputState)
-
isFocused
final Boolean isFocused()
focused flag for this component. Only ever true if focusable is true.
- Since:
1.4.2
-
isFocusable
final Boolean isFocusable()
-
setup
Boolean setup(PolyUI polyUI)
give this a PolyUI reference.
You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes, or operations that require access to PolyUI things, like PolyUI.settings or PolyUI.translator
this method is called once, and only once.
-
accept
@MustBeInvokedByOverriders() Boolean accept(Event event)
called when this component receives an event.
- Returns:
true if the event should be consumed (cancelled so no more handlers are called), false otherwise.
-
clearHandlers
@ApiStatus.Experimental() final Unit clearHandlers()
Clear all event handlers for this component.
- Since:
1.1.61
-
on
final <E extends Event, S extends Inputtable> S on(S $self, E event, Function2<S, E, Boolean> handler)
-
addEventhandler
final <E extends Event, S extends Inputtable> S addEventhandler(S $self, E event, Function2<S, E, Unit> handler)
-
hasListenersFor
final Boolean hasListenersFor(Class<out Event> event)
returns
trueif this component has any non-specific event handlers registered for it.pass an event instance to this method for specific events.
- Since:
1.1.61
-
hasListenersFor
final Boolean hasListenersFor(Event event)
returns
trueif this component has any specific event handlers registered for it.pass a class instance to this method for non-specific events.
- Since:
1.1.71
-
-
-
-