Selection

This object is available to unprivileged JavaScript. It implements the following interfaces:

Properties

readonly Node anchorNode

The node representing one end of the selection.

readonly PRInt32 anchorOffset

The offset within the (text) node where the selection begins.

readonly Node focusNode

The node with keyboard focus.

readonly PRInt32 focusOffset

The offset within the (text) node where focus starts.

readonly boolean isCollapsed

Indicates if the selection is collapsed or not.

readonly PRInt32 rangeCount

Returns the number of ranges in the selection.


Methods

void addRange ( Range range ) void collapse ( Node parentNode , PRInt32 offset ) void collapseToEnd ( ) void collapseToStart ( ) boolean containsNode ( Node node , boolean entirelyContained ) void deleteFromDocument ( ) void extend ( Node parentNode , PRInt32 offset ) Range getRangeAt ( PRInt32 index ) void removeAllRanges ( ) void removeRange ( Range range ) void selectAllChildren ( Node parentNode ) void selectionLanguageChange ( boolean langRTL ) PRUnichar* toString ( )

void addRange ( Range range )

Adds a range to the current selection.

Arguments:
range

void collapse ( Node parentNode , PRInt32 offset )

Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.

Arguments:
parentNode: The given dom node where the selection will be set
offset: Where in given dom node to place the selection (the offset into the given node)

void collapseToEnd ( )

Collapses the whole selection to a single point at the end of the current selection (irrespective of direction). If content is focused and editable, the caret will blink there.


void collapseToStart ( )

Collapses the whole selection to a single point at the start of the current selection (irrespective of direction). If content is focused and editable, the caret will blink there.


boolean containsNode ( Node node , boolean entirelyContained )

The value of entirelyContained determines the detail of the search to determine if the selection contains the node. If entirelyContained is set to PR_TRUE, t or false if

Arguments:
node: The node where the selection will be extended to
entirelyContained: Whether

void deleteFromDocument ( )

Deletes this selection from document the nodes belong to.


void extend ( Node parentNode , PRInt32 offset )

Extends the selection by moving the focus to the specified node and offset, preserving the anchor postion. The new selection end result will always be from the anchor to the new focus, regardless of direction.

Arguments:
parentNode: The node where the selection will be extended to
offset: Where in node to place the offset in the new focused node

Range getRangeAt ( PRInt32 index )

Returns the range at the specified index.

Arguments:
index

void removeAllRanges ( )

Removes all ranges from the current selection.


void removeRange ( Range range )

Removes a range from the current selection.

Arguments:
range

void selectAllChildren ( Node parentNode )

Adds all children of the specified node to the selection.

Arguments:
parentNode: the parent of the children to be added to the selection.

void selectionLanguageChange ( boolean langRTL )

Modifies the cursor Bidi level after a change in keyboard direction

Arguments:
langRTL: is PR_TRUE if the new language is right-to-left or PR_FALSE if the new language is left-to-right.

PRUnichar* toString ( )

Returns the whole selection into a plain text string.

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com