Class TextInput

All Implemented Interfaces:
TextComponent, Serializable
Direct Known Subclasses:
PasswordInput

public class TextInput extends AbstractTextComponent
Text input is a single line text component which can be used to enter text.
See Also:
  • Constructor Details

    • TextInput

      public TextInput()
      Default constructor. Used to create component instance without any parameters.

      Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.

    • TextInput

      public TextInput(float x, float y, float width, float height)
      Constructor with position and size parameters.
      Parameters:
      x - x position position in parent component.
      y - y position position in parent component.
      width - width of component.
      height - height of component.
    • TextInput

      public TextInput(org.joml.Vector2f position, org.joml.Vector2f size)
      Constructor with position and size parameters.
      Parameters:
      position - position position in parent component.
      size - size of component.
    • TextInput

      public TextInput(String text)
      Default constructor with text to set.

      Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.

      Parameters:
      text - text to set.
    • TextInput

      public TextInput(String text, float x, float y, float width, float height)
      Constructor with text, position and size parameters.
      Parameters:
      text - text to set.
      x - x position position in parent component.
      y - y position position in parent component.
      width - width of component.
      height - height of component.
    • TextInput

      public TextInput(String text, org.joml.Vector2f position, org.joml.Vector2f size)
      Constructor with text, position and size parameters.
      Parameters:
      text - text to set.
      position - position position in parent component.
      size - size of component.
  • Method Details

    • 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

      public String getSelection()
      Returns selected text.
      Returns:
      selected text.
    • addTextInputContentChangeEventListener

      public void addTextInputContentChangeEventListener(EventListener<TextInputContentChangeEvent> eventListener)
      Used to add event listener for text input content change event.
      Parameters:
      eventListener - event listener to add.
    • getTextInputContentChangeEvents

      public List<EventListener<TextInputContentChangeEvent>> getTextInputContentChangeEvents()
      Returns all event listeners for text input content change event.
      Returns:
      all event listeners for text input content change event.
    • removeTextInputContentChangeEventListener

      public void removeTextInputContentChangeEventListener(EventListener<TextInputContentChangeEvent> eventListener)
      Used to remove event listener for text input content change event.
      Parameters:
      eventListener - event listener to remove.
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Component
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Component