Selection class

A object represents the range of text selected by the user or the current position of the caret. To obtain a object for examination or manipulation, 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.

Note: Anchor and focus should not be confused with the start and end positions of a selection. The anchor can be placed before the focus or vice-versa, depending on the direction you made your selection.

Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Selection()
factory

Properties

anchorNode Node?

Available on Selection, provided by the PropsSelection extension

no setter
anchorOffset int

Available on Selection, provided by the PropsSelection extension

no setter
focusNode Node?

Available on Selection, provided by the PropsSelection extension

no setter
focusOffset int

Available on Selection, provided by the PropsSelection extension

no setter
hashCode int
The hash code for this object.
no setterinherited
isCollapsed bool

Available on Selection, provided by the PropsSelection extension

no setter
rangeCount int

Available on Selection, provided by the PropsSelection extension

no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String

Available on Selection, provided by the PropsSelection extension

no setter

Methods

addRange(Range range) → void

Available on Selection, provided by the PropsSelection extension

collapse(Node? node, [int? offset = 0]) → void

Available on Selection, provided by the PropsSelection extension

collapseToEnd() → void

Available on Selection, provided by the PropsSelection extension

collapseToStart() → void

Available on Selection, provided by the PropsSelection extension

containsNode(Node node, [bool? allowPartialContainment = false]) bool

Available on Selection, provided by the PropsSelection extension

deleteFromDocument() → void

Available on Selection, provided by the PropsSelection extension

empty() → void

Available on Selection, provided by the PropsSelection extension

extend(Node node, [int? offset = 0]) → void

Available on Selection, provided by the PropsSelection extension

getRangeAt(int index) Range

Available on Selection, provided by the PropsSelection extension

modify([String? alter, String? direction, String? granularity]) → void

Available on Selection, provided by the PropsSelection extension

mToString() String

Available on Selection, provided by the PropsSelection extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeAllRanges() → void

Available on Selection, provided by the PropsSelection extension

removeRange(Range range) → void

Available on Selection, provided by the PropsSelection extension

selectAllChildren(Node node) → void

Available on Selection, provided by the PropsSelection extension

setBaseAndExtent(Node anchorNode, int anchorOffset, Node focusNode, int focusOffset) → void

Available on Selection, provided by the PropsSelection extension

setPosition(Node? node, [int? offset = 0]) → void

Available on Selection, provided by the PropsSelection extension

toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited