class Selection extends Object
A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or modification, call window.getSelection().
A user may make a selection from left to right (in document order) or right to left (reverse of document order). The anchor is where the user began the selection and the focus is where the user ends the selection. If you make a selection with a desktop mouse, the anchor is placed where you pressed the mouse button and the focus is placed where you released the mouse button. Anchor and focus should not be confused with the start and end positions of a selection, since anchor can be placed before the focus or vice versa, depending on the direction you made your selection.
- Annotations
- @RawJSType() @native() @JSGlobal( "Selection" )
- See also
https://developer.mozilla.org/en-US/docs/Web/API/Selection
- Alphabetic
- By Inheritance
- Selection
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Selection()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addRange(range: Range): Unit
A Range object that will be added to the selection.
-
def
anchorNode: Node
Read only: Returns the Node in which the selection begins.
-
def
anchorOffset: Int
Read only: Returns a number representing the offset of the selection's anchor within the anchorNode.
Read only: Returns a number representing the offset of the selection's anchor within the anchorNode. If anchorNode is a text node, this is the number of characters within anchorNode preceding the anchor. If anchorNode is an element, this is the number of child nodes of the anchorNode preceding the anchor.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collapse(parentNode: Node, offset: Int): Unit
Collapses the current selection to a single point.
Collapses the current selection to a single point.
- parentNode
The caret location will be within this node.
- offset
The offset in parentNode to which the selection will be collapsed.
-
def
collapseToEnd(): Unit
Collapses the selection to the end of the last range in the selection.
-
def
collapseToStart(): Unit
Collapses the selection to the start of the first range in the selection.
-
def
containsNode(aNode: Node, aPartlyContained: Boolean = js.native): Boolean
Indicates if a certain node is part of the selection.
Indicates if a certain node is part of the selection.
- aNode
The node that is being looked for whether it is part of the selection
- aPartlyContained
When true, containsNode() returns true when a part of the node is part of the selection. When false, containsNode() only returns true when the entire node is part of the selection.
-
def
deleteFromDocument(): Unit
Deletes the selection's content from the document.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
extend(parentNode: Node, offset: Int): Unit
Moves the focus of the selection to a specified point.
Moves the focus of the selection to a specified point.
- parentNode
The node within which the focus will be moved.
- offset
The offset position within parentNode where the focus will be moved to.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
focusNode: Node
Read only: Returns the Node in which the selection ends.
-
def
focusOffset: Int
Read only: Returns a number representing the offset of the selection's anchor within the focusNode.
Read only: Returns a number representing the offset of the selection's anchor within the focusNode. If focusNode is a text node, this is the number of characters within focusNode preceding the focus. If focusNode is an element, this is the number of child nodes of the focusNode preceding the focus.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getRangeAt(index: Int): Range
Returns a Range object representing one of the ranges currently selected.
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
isCollapsed: Boolean
Read only: Returns a Boolean indicating whether the selection's start and end points are at the same position.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
def
modify(alter: String, direction: String, granularity: String): Unit
Changes the current selection.
Changes the current selection.
- alter
The type of change to apply. Specify "move" to move the current cursor position or "extend" to extend the current selection.
- direction
The direction in which to adjust the current selection. You can specify "forward" or "backward" to adjust in the appropriate direction based on the language at the selection point. If you want to adjust in a specific direction, you can specify "left" or "right".
- granularity
The distance to adjust the current selection or cursor position. You can move by "character", "word", "sentence", "line", "paragraph", "lineboundary", "sentenceboundary", "paragraphboundary", or "documentboundary".
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
rangeCount: Int
Read only: Returns the number of ranges in the selection.
-
def
removeAllRanges(): Unit
Removes all ranges from the selection.
-
def
removeRange(range: Range): Unit
Removes a range from the selection.
-
def
selectAllChildren(): Unit
Adds all the children of the specified node to the selection.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )