Class TextState
java.lang.Object
com.spinyowl.legui.component.optional.TextState
- All Implemented Interfaces:
Serializable
Used to hold text state of components.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Used to create TextState with predefined text.TextState(String text, BiConsumer<String, String> textSetCallback) Used to create TextState with predefined text.TextState(BiConsumer<String, String> textSetCallback) Used to create TextState with predefined text. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns caret position.Absolute caret X position.Absolute caret Y position.intReturns end selection index.intReturns mouse caret position.Returns selected text.intReturns start selection index.getText()Returns text.floatfloatinthashCode()booleanReturns true if text is editable.intlength()Returns text length.voidsetCaretPosition(int caretPosition) Used to set caret position.voidUsed by renderer to set absolute caret x position.voidUsed by renderer to set absolute caret y position.voidsetEditable(boolean editable) Used to set editable text or not.voidsetEndSelectionIndex(int endSelectionIndex) Used to set end selection index.voidsetMouseCaretPosition(int mouseCaretPosition) Used to set mouse caret position.voidsetStartSelectionIndex(int startSelectionIndex) Used to set start selection index.voidUsed to set new text.voidsetTextHeight(float textHeight) voidsetTextSetCallback(BiConsumer<String, String> textSetCallback) voidsetTextWidth(float textWidth) voidsetValidator(Predicate<String> validator) toString()
-
Field Details
-
INTEGER_VALIDATOR
-
NUMBER_VALIDATOR
-
-
Constructor Details
-
TextState
public TextState()Default constructor. -
TextState
Used to create TextState with predefined text.- Parameters:
text- text to set.
-
TextState
Used to create TextState with predefined text.- Parameters:
textSetCallback- callback to call some extra functionality aftersetText(String). Accepts old value as first arg, and new value as the second arg.
-
TextState
Used to create TextState with predefined text.- Parameters:
text- text to set.textSetCallback- callback to call some extra functionality aftersetText(String). Accepts old value as first arg, and new value as the second arg.
-
-
Method Details
-
getText
Returns text.- Returns:
- text.
-
setText
Used to set new text.- Parameters:
text- new text.
-
length
public int length()Returns text length.- Returns:
- text length.
- See Also:
-
getMouseCaretPosition
public int getMouseCaretPosition()Returns mouse caret position.- Returns:
- mouse caret position.
-
setMouseCaretPosition
public void setMouseCaretPosition(int mouseCaretPosition) Used to set mouse caret position.- Parameters:
mouseCaretPosition- mouse caret position to set.
-
isEditable
public boolean isEditable()Returns true if text is editable.- Returns:
- true if text is editable.
-
setEditable
public void setEditable(boolean editable) Used to set editable text or not.- Parameters:
editable- editable text or not.
-
getCaretPosition
public int getCaretPosition()Returns caret position.- Returns:
- caret position.
-
setCaretPosition
public void setCaretPosition(int caretPosition) Used to set caret position.- Parameters:
caretPosition- caret position to set.
-
getStartSelectionIndex
public int getStartSelectionIndex()Returns start selection index.- Returns:
- start selection index.
-
setStartSelectionIndex
public void setStartSelectionIndex(int startSelectionIndex) Used to set start selection index.- Parameters:
startSelectionIndex- start selection index to set.
-
getEndSelectionIndex
public int getEndSelectionIndex()Returns end selection index.- Returns:
- end selection index.
-
setEndSelectionIndex
public void setEndSelectionIndex(int endSelectionIndex) Used to set end selection index.- Parameters:
endSelectionIndex- end selection index to set.
-
getSelection
Returns selected text.- Returns:
- selected text.
-
getTextWidth
public float getTextWidth() -
setTextWidth
public void setTextWidth(float textWidth) -
getTextHeight
public float getTextHeight() -
setTextHeight
public void setTextHeight(float textHeight) -
getCaretX
Absolute caret X position.- Returns:
- absolute caret X position.
-
setCaretX
Used by renderer to set absolute caret x position.- Parameters:
caretX- caret x position.
-
getCaretY
Absolute caret Y position.- Returns:
- absolute caret Y position.
-
setCaretY
Used by renderer to set absolute caret y position.- Parameters:
caretY- caret x position.
-
getTextSetCallback
-
setTextSetCallback
-
equals
-
hashCode
public int hashCode() -
toString
-
getValidator
-
setValidator
-