Class SelectableTextSelectionDelegate
java.lang.Object
org.htmlunit.html.impl.SelectableTextSelectionDelegate
- All Implemented Interfaces:
Serializable, SelectionDelegate
Contains standard selection-related functionality used by various input elements.
From the HTML5 spec:
Mostly for historical reasons, in addition to the browsing context's selection, each textarea and input element has an independent selection. These are the text field selections.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SelectableTextInputThe owner element.private final SimpleRangeThe field selection, which is independent of the browsing context's selection. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance for the specified element. -
Method Summary
Modifier and TypeMethodDescriptionReturns the selected text in the owner element, ornullif there is no selected text.intReturns the end position of the selected text in the owner element.intReturns the start position of the selected text in the owner element.voidselect()Focuses the owner element and selects all of its text.voidsetSelectionEnd(int selectionEnd) Sets the end position of the selected text in the owner element.voidsetSelectionStart(int selectionStart) Sets the start position of the selected text in the owner element.
-
Field Details
-
element_
The owner element. -
selection_
The field selection, which is independent of the browsing context's selection.
-
-
Constructor Details
-
SelectableTextSelectionDelegate
Creates a new instance for the specified element.- Parameters:
element- the owner element
-
-
Method Details
-
select
public void select()Focuses the owner element and selects all of its text. -
getSelectedText
Returns the selected text in the owner element, ornullif there is no selected text.- Returns:
- the selected text in the owner element, or
nullif there is no selected text
-
getSelectionStart
public int getSelectionStart()Returns the start position of the selected text in the owner element.- Specified by:
getSelectionStartin interfaceSelectionDelegate- Returns:
- the start position of the selected text in the owner element
-
setSelectionStart
public void setSelectionStart(int selectionStart) Sets the start position of the selected text in the owner element.- Specified by:
setSelectionStartin interfaceSelectionDelegate- Parameters:
selectionStart- the start position of the selected text in the owner element
-
getSelectionEnd
public int getSelectionEnd()Returns the end position of the selected text in the owner element.- Specified by:
getSelectionEndin interfaceSelectionDelegate- Returns:
- the end position of the selected text in the owner element
-
setSelectionEnd
public void setSelectionEnd(int selectionEnd) Sets the end position of the selected text in the owner element.- Specified by:
setSelectionEndin interfaceSelectionDelegate- Parameters:
selectionEnd- the end position of the selected text in the owner element
-