public class Selection extends HtmlUnitScriptable
Selection
.org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
NOT_FOUND
Constructor and Description |
---|
Selection() |
Modifier and Type | Method and Description |
---|---|
void |
addRange(Range range)
Adds a range to the selection.
|
void |
collapse(Node parentNode,
int offset)
Collapses the current selection to a single point.
|
void |
collapseToEnd()
Moves the anchor of the selection to the same point as the focus.
|
void |
collapseToStart()
Moves the focus of the selection to the same point at the anchor.
|
void |
empty()
Cancels the current selection, sets the selection type to none.
|
void |
extend(Node parentNode,
int offset)
Moves the focus of the selection to a specified point.
|
Node |
getAnchorNode()
Returns the node in which the selection begins.
|
int |
getAnchorOffset()
Returns the number of characters that the selection's anchor is offset within the anchor node.
|
Object |
getDefaultValue(Class<?> hint)
Returns the JavaScript default value of this object.
|
Node |
getFocusNode()
Returns the node in which the selection ends.
|
int |
getFocusOffset()
Returns the number of characters that the selection's focus is offset within the focus node.
|
Range |
getRangeAt(int index)
Returns the range at the specified index.
|
int |
getRangeCount()
Returns the number of ranges in the selection.
|
String |
getType()
Returns the type of selection (IE only).
|
boolean |
isIsCollapsed()
Returns a boolean indicating whether the selection's start and end points are at the same position.
|
void |
jsConstructor()
JavaScript constructor.
|
String |
jsToString() |
void |
removeAllRanges()
Removes all ranges from the selection.
|
void |
removeRange(Range range)
Removes a range from the selection.
|
void |
selectAllChildren(Node parentNode)
Adds all the children of the specified node to the selection.
|
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowFromTopCallScope, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
public void jsConstructor()
public String jsToString()
public Object getDefaultValue(Class<?> hint)
getDefaultValue
in interface org.htmlunit.corejs.javascript.Scriptable
getDefaultValue
in class HtmlUnitScriptable
hint
- a hint as to the format of the default value (ignored in this case)public Node getAnchorNode()
public int getAnchorOffset()
public Node getFocusNode()
public int getFocusOffset()
public boolean isIsCollapsed()
public int getRangeCount()
public String getType()
public void addRange(Range range)
range
- the range to addpublic void removeRange(Range range)
range
- the range to removepublic void removeAllRanges()
public Range getRangeAt(int index)
index
- the index of the range to returnpublic void collapse(Node parentNode, int offset)
parentNode
- the caret location will be within this nodeoffset
- the caret will be placed this number of characters from the beginning of the parentNode's textpublic void collapseToEnd()
public void collapseToStart()
public void empty()
public void extend(Node parentNode, int offset)
parentNode
- the node within which the focus will be movedoffset
- the number of characters from the beginning of parentNode's text the focus will be placedpublic void selectAllChildren(Node parentNode)
parentNode
- all children of parentNode will be selected; parentNode itself is not part of the selectionCopyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.