Packages

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

Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Selection
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Selection()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addRange(range: Range): Unit

    A Range object that will be added to the selection.

  5. def anchorNode: Node

    Read only: Returns the Node in which the selection begins.

  6. 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.

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. 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.

  10. def collapseToEnd(): Unit

    Collapses the selection to the end of the last range in the selection.

  11. def collapseToStart(): Unit

    Collapses the selection to the start of the first range in the selection.

  12. 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.

  13. def deleteFromDocument(): Unit

    Deletes the selection's content from the document.

  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  16. 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.

  17. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def focusNode: Node

    Read only: Returns the Node in which the selection ends.

  19. 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.

  20. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  21. def getRangeAt(index: Int): Range

    Returns a Range object representing one of the ranges currently selected.

  22. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  24. def isCollapsed: Boolean

    Read only: Returns a Boolean indicating whether the selection's start and end points are at the same position.

  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  27. 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".

  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. final def notify(): Unit
    Definition Classes
    AnyRef
  30. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  31. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  32. def rangeCount: Int

    Read only: Returns the number of ranges in the selection.

  33. def removeAllRanges(): Unit

    Removes all ranges from the selection.

  34. def removeRange(range: Range): Unit

    Removes a range from the selection.

  35. def selectAllChildren(): Unit

    Adds all the children of the specified node to the selection.

  36. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  37. def toLocaleString(): String
    Definition Classes
    Object
  38. def toString(): String
    Definition Classes
    AnyRef → Any
  39. def valueOf(): Any
    Definition Classes
    Object
  40. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped