Package org.htmlunit.html.impl
Class SelectableTextSelectionDelegate
- java.lang.Object
-
- org.htmlunit.html.impl.SelectableTextSelectionDelegate
-
- All Implemented Interfaces:
java.io.Serializable
,SelectionDelegate
public class SelectableTextSelectionDelegate extends java.lang.Object implements 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private SelectableTextInput
element_
The owner element.private SimpleRange
selection_
The field selection, which is independent of the browsing context's selection.
-
Constructor Summary
Constructors Constructor Description SelectableTextSelectionDelegate(SelectableTextInput element)
Creates a new instance for the specified element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getSelectedText()
Returns the selected text in the owner element, ornull
if there is no selected text.int
getSelectionEnd()
Returns the end position of the selected text in the owner element.int
getSelectionStart()
Returns the start position of the selected text in the owner element.void
select()
Focuses the owner element and selects all of its text.void
setSelectionEnd(int selectionEnd)
Sets the end position of the selected text in the owner element.void
setSelectionStart(int selectionStart)
Sets the start position of the selected text in the owner element.
-
-
-
Field Detail
-
element_
private final SelectableTextInput element_
The owner element.
-
selection_
private final SimpleRange selection_
The field selection, which is independent of the browsing context's selection.
-
-
Constructor Detail
-
SelectableTextSelectionDelegate
public SelectableTextSelectionDelegate(SelectableTextInput element)
Creates a new instance for the specified element.- Parameters:
element
- the owner element
-
-
Method Detail
-
select
public void select()
Focuses the owner element and selects all of its text.
-
getSelectedText
public java.lang.String getSelectedText()
Returns the selected text in the owner element, ornull
if there is no selected text.- Returns:
- the selected text in the owner element, or
null
if there is no selected text
-
getSelectionStart
public int getSelectionStart()
Returns the start position of the selected text in the owner element.- Specified by:
getSelectionStart
in 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:
setSelectionStart
in 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:
getSelectionEnd
in 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:
setSelectionEnd
in interfaceSelectionDelegate
- Parameters:
selectionEnd
- the end position of the selected text in the owner element
-
-