Module org.htmlunit

Class HtmlSelectableTextInput

All Implemented Interfaces:
Serializable, Cloneable, DisabledElement, SelectableTextInput, SubmittableElement, ValidatableHtmlElement, Element, Node
Direct Known Subclasses:
HtmlDateInput, HtmlEmailInput, HtmlNumberInput, HtmlPasswordInput, HtmlTelInput, HtmlTextInput, HtmlTimeInput, HtmlUrlInput

public abstract class HtmlSelectableTextInput extends HtmlInput implements SelectableTextInput
Abstract parent class to share SelectableTextInput implementation and typing support.
Author:
Ronald Brill
See Also:
  • Method Details

    • setValue

      public void setValue(String newValue)
      Sets the value.
      Overrides:
      setValue in class HtmlInput
      Parameters:
      newValue - the new value
    • doType

      protected void doType(char c, boolean lastType)
      Performs the effective type action, called after the keyPress event and before the keyUp event.
      Overrides:
      doType in class HtmlElement
      Parameters:
      c - the character you with to simulate typing
      lastType - is this the last character to type
    • doType

      protected void doType(int keyCode, boolean lastType)
      Performs the effective type action, called after the keyPress event and before the keyUp event.

      An example of predefined values is KeyboardEvent.DOM_VK_PAGE_DOWN.

      Overrides:
      doType in class HtmlElement
      Parameters:
      keyCode - the key code wish to simulate typing
      lastType - is this the last to type
    • typeDone

      protected void typeDone(String newValue, boolean notifyAttributeChangeListeners)
      Called from DoTypeProcessor.
      Overrides:
      typeDone in class HtmlElement
      Parameters:
      newValue - the new value
      notifyAttributeChangeListeners - to notify the associated HtmlAttributeChangeListeners
    • setText

      public void setText(String text)
      Sets the text in this element.
      Specified by:
      setText in interface SelectableTextInput
      Parameters:
      text - the text to put in this element
    • getText

      public String getText()
      Returns all the text in this element.
      Specified by:
      getText in interface SelectableTextInput
      Returns:
      all the text in this element
    • select

      public void select()
      Focuses this element and selects all of its text.
      Specified by:
      select in interface SelectableTextInput
    • getSelectedText

      public String getSelectedText()
      Returns the selected text in this element, or null if there is no selected text in this element.
      Specified by:
      getSelectedText in interface SelectableTextInput
      Returns:
      the selected text in this element, or null if there is no selected text in this element
    • getSelectionStart

      public int getSelectionStart()
      Returns the start position of the selected text in this element.
      Specified by:
      getSelectionStart in interface SelectableTextInput
      Returns:
      the start position of the selected text in this element
    • setSelectionStart

      public void setSelectionStart(int selectionStart)
      Sets the start position of the selected text in this element.
      Specified by:
      setSelectionStart in interface SelectableTextInput
      Parameters:
      selectionStart - the start position of the selected text in this element
    • getSelectionEnd

      public int getSelectionEnd()
      Returns the end position of the selected text in this element.
      Specified by:
      getSelectionEnd in interface SelectableTextInput
      Returns:
      the end position of the selected text in this element
    • setSelectionEnd

      public void setSelectionEnd(int selectionEnd)
      Sets the end position of the selected text in this element.
      Specified by:
      setSelectionEnd in interface SelectableTextInput
      Parameters:
      selectionEnd - the end position of the selected text in this element
    • cloneNode

      public DomNode cloneNode(boolean deep)
      Specified by:
      cloneNode in interface Node
      Overrides:
      cloneNode in class HtmlElement