nsISelection

IID:B2C7ED59-8634-4352-9E37-5484C8B6E4E1
Inherits From:nsISupports
Status:FROZEN

Interface for manipulating and querying the current selected range of nodes within the document.


Properties

readonly nsIDOMNode anchorNode

The node representing one end of the selection.

readonly PRInt32 anchorOffset

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

readonly nsIDOMNode focusNode

The node with keyboard focus.

readonly PRInt32 focusOffset

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

readonly PRBool isCollapsed

Indicates if the selection is collapsed or not.

readonly PRInt32 rangeCount

Returns the number of ranges in the selection.


Methods

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

void addRange ( nsIDOMRange range )

Adds a range to the current selection.

Arguments:
range

void collapse ( nsIDOMNode 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.


PRBool containsNode ( nsIDOMNode node , PRBool 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 ( nsIDOMNode 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

nsIDOMRange getRangeAt ( PRInt32 index )

Returns the range at the specified index.

Arguments:
index

void removeAllRanges ( )

Removes all ranges from the current selection.


void removeRange ( nsIDOMRange range )

Removes a range from the current selection.

Arguments:
range

void selectAllChildren ( nsIDOMNode 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 ( PRBool 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.


References

This interface is the type of the following properties:

nsIEditor.selection

This interface is passed as an argument to the following methods:

nsIEditActionListener.DidDeleteSelection, nsIEditActionListener.WillDeleteSelection, nsIHTMLEditor.checkSelectionStateForAnonymousButtons, nsISelectionListener.notifySelectionChanged

This interface is returned from the following methods:

nsIDOMWindow.getSelection, nsISelectionController.getSelection

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com