Class TextInput
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classTextInput.ChangedEvent
-
Field Summary
Fields Modifier and Type Field Description private final TextInputPropertiespropertiesprivate transient Texttextprivate Stringtxtprivate final transient Booleanfocusedprivate final Stringselectionprivate final transient Booleanerroredprivate transient StringlastValidprivate final Translator.Textplaceholderprivate transient Color.Animatedcolorprivate transient Drawableparentprivate transient Layoutlayoutprivate transient BooleanconsumesHoverprivate Booleandisabledprivate Vec2<Unit>sizeprivate final transient HashMap<Event, Function2<Drawable, Event, Boolean>>eventHandlersprivate transient StringsimpleNameprivate transient Rendererrendererprivate transient PolyUIpolyUIprivate BooleanacceptsInputprivate final transient ByteinitStageprivate final transient BooleanmouseOverprivate Booleanrendersprivate Floatxprivate Floatyprivate Floatwidthprivate Floatheightprivate Booleanexistsprivate transient FloattrueXprivate transient FloattrueYprivate final Unit.TypeatTypeprivate final Unit.TypesizeTypeprivate final BooleanisDynamicprivate Doublerotationprivate DoubleskewXprivate DoubleskewYprivate FloatscaleXprivate FloatscaleYprivate Floatalphaprivate transient Floatacxprivate transient Floatacyprivate final Vec2<Unit>atprivate final BooleanrawResize
-
Constructor Summary
Constructors Constructor Description TextInput(TextInputProperties properties, Vec2<Unit> at, Vec2<Unit> size, Translator.Text placeholder, PolyImage image, Translator.Text title, Translator.Text hint, Translator.Text initialText, Unit fontSize, Function1<EventDSL<TextInput>, Unit> events)
-
Method Summary
Modifier and Type Method Description TextInputPropertiesgetProperties()final TextgetText()final UnitsetText(Text text)final StringgetTxt()final UnitsetTxt(String txt)final BooleangetFocused()final StringgetSelection()final BooleangetErrored()represents if TextInputProperties.sanitizationFunction returned false (text no good) final StringgetLastValid()final UnitsetLastValid(String lastValid)final Translator.TextgetPlaceholder()UnitpreRender(Long deltaTimeNanos)pre-render functions, such as applying transforms. Unitrender()draw script for this drawable. Booleanaccept(Event event)called when this drawable receives an event. Booleanaccept(FocusedEvent event)Accept a FocusedEvent and handle it. final UnitcaretPos()final UnitselectWordAroundCaret()Unitrescale(Float scaleX, Float scaleY)Method that is called when the physical size of the total window area changes. final UnittoLastSpace()final UnitdropToLastSpace()final UnittoNextSpace()final Unitback()final Unitforward()UnitonColorsChanged(Colors colors)Function that is called when the colors attached to this drawable change. Unitreset()Use this function to reset your drawable's PolyText if it is using one. final UnitclearSelection()Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. UnitcalculateBounds()Calculate the position and size of this drawable. UnitonInitComplete()This function is called when initialization of a drawable is complete, so it has been fully calculated. Vec2<Unit>calculateSize()Implement this function to return the size of this drawable, if no size is specified during construction. -
Methods inherited from class org.polyfrost.polyui.component.Component
addKeyframes, addOperation, canBeRemoved, debugRender, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, onFontsChanged, recolor, setColor, setConsumesHover, setDisabled, setLayout, setParent, setProperties, setSize, toString, trueX, trueY, wantRedraw -
Methods inherited from class org.polyfrost.polyui.component.Drawable
addEventHandler, addEventhandler, animateBy, animateTo, clone, debugPrint, doDynamicSize, events, fadeBy, fadeTo, getAcceptsInput, getAcx, getAcy, getAlpha, getAt, getAtType, getContainingLayout, getEventHandlers, getExists, getHeight, getInitStage, getMouseOver, getPolyUI, getRawResize, getRenderer, getRenders, getRotation, getScaleX, getScaleY, getSimpleName, getSizeType, getSkewX, getSkewY, getTrueX, getTrueY, getWidth, getX, getY, intersects, isDynamic, isInside, isInside, moveBy, moveTo, onParentInitComplete, postRender, removeOperation, resize, rotateBy, rotateTo, scaleBy, scaleTo, setAcceptsInput, setAcx, setAcy, setAlpha, setExists, setHeight, setPolyUI, setRenderer, setRenders, setRotation, setScaleX, setScaleY, setSimpleName, setSkewX, setSkewY, setTrueX, setTrueY, setWidth, setX, setY, skewBy, skewTo -
Methods inherited from class org.polyfrost.polyui.component.Focusable
accept -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
TextInput
TextInput(TextInputProperties properties, Vec2<Unit> at, Vec2<Unit> size, Translator.Text placeholder, PolyImage image, Translator.Text title, Translator.Text hint, Translator.Text initialText, Unit fontSize, Function1<EventDSL<TextInput>, Unit> events)
-
-
Method Detail
-
getProperties
TextInputProperties getProperties()
-
getFocused
final Boolean getFocused()
-
getSelection
final String getSelection()
-
getErrored
final Boolean getErrored()
represents if TextInputProperties.sanitizationFunction returned false (text no good)
-
getLastValid
final String getLastValid()
-
setLastValid
final Unit setLastValid(String lastValid)
-
getPlaceholder
final Translator.Text getPlaceholder()
-
preRender
Unit preRender(Long deltaTimeNanos)
pre-render functions, such as applying transforms. In this method, you should set needsRedraw to true if you have something to redraw for the next frame.
- Parameters:
deltaTimeNanos- the time in nanoseconds since the last frame.
-
accept
Boolean accept(Event event)
called when this drawable receives an event.
make sure to call Drawable.accept!
-
accept
Boolean accept(FocusedEvent event)
Accept a FocusedEvent and handle it.
-
selectWordAroundCaret
final Unit selectWordAroundCaret()
-
rescale
Unit rescale(Float scaleX, Float scaleY)
Method that is called when the physical size of the total window area changes.
-
toLastSpace
final Unit toLastSpace()
-
dropToLastSpace
final Unit dropToLastSpace()
-
toNextSpace
final Unit toNextSpace()
-
onColorsChanged
Unit onColorsChanged(Colors colors)
Function that is called when the colors attached to this drawable change.
If this is a layout, the colors will change, and all its children and components will be notified and updated accordingly.
Make sure to call super.onColorsChanged() if you override this!
-
clearSelection
final Unit clearSelection()
-
setup
Unit setup(Renderer renderer, PolyUI polyUI)
give this a renderer reference and a PolyUI reference.
You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes.
If you need a method that has access to component's sizes, see here or here (if you are operating on yourself only).
this method is called once, and only once.
-
calculateBounds
Unit calculateBounds()
Calculate the position and size of this drawable. Make sure to call doDynamicSize in this method to avoid issues with sizing.
This method is called once the layout is populated for children and component, and when a recalculation is requested.
The value of layout's bounds will be updated after this method is called, so do not use layout's bounds as an updated value in this method.
-
onInitComplete
Unit onInitComplete()
This function is called when initialization of a drawable is complete, so it has been fully calculated.
This function is called once, and only once.
-
calculateSize
Vec2<Unit> calculateSize()
Implement this function to return the size of this drawable, if no size is specified during construction.
This should be so that if the drawable can determine its own size (for example, it is an image), then the size parameter in the constructor can be omitted using:
size: Vec2<org.polyfrost.polyui.unit.Unit>? = null;and this method needs to be implemented!Otherwise, the size parameter in the constructor must be specified.
-
-
-
-