nsISupports
Last changed in Gecko 13.0 (Firefox 13.0 / Thunderbird 13.0 / SeaMonkey 2.10)Interface for manipulating and querying the current selected range of nodes within the document.
Implemented by: ?????????????????????????????????????
. To create an instance, use:
Implemented by: ?????????????????????????????????????
as a service:
var selection = Components.classes["@mozilla.org/????????????????????????????"] .createInstance(Components.interfaces.nsISelection);
void addRange(in |
void collapse(in nsIDOMNode parentNode, in long offset); |
[noscript,notxpcom,nostdcall] boolean collapsed(); |
void collapseNative(in Native code only! |
void collapseToEnd(); |
void collapseToStart(); |
boolean containsNode(in nsIDOMNode node, in boolean partlyContained); |
void deleteFromDocument(); |
void extend(in nsIDOMNode parentNode, in long offset); |
void extendNative(in Native code only! |
nsIDOMRange getRangeAt(in long index); |
void modify(in DOMString alter, in DOMString direction, in DOMString granularity); |
void removeAllRanges(); |
void removeRange(in nsIDOMRange range); |
void selectAllChildren(in |
void selectionLanguageChange(in boolean langRTL); |
DOMString toString(); |
Attribute | Type | Description |
anchorNode |
|
Returns the node in which the selection begins. Read only. |
anchorOffset |
long |
The offset within the (text) node where the selection begins. Read only. |
focusNode |
|
Returns the node in which the selection ends. Read only. |
focusOffset |
long |
The offset within the (text) node where the selection ends. Read only. |
isCollapsed |
boolean |
Indicates if the selection is collapsed() or not. Read only. |
rangeCount |
long |
Returns the number of ranges in the selection. Read only. |
Adds a nsIDOMRange to the current selection.
void addRange( in nsIDOMRange range );
range
Collapses the selection to a single point, at the specified offset in the given nsIDOMNode. When the selection is collapsed()
, and the content is focused and editable, the caret will blink there.
void collapse( in nsIDOMNode parentNode, in long offset );
parentNode
offset
[noscript,notxpcom,nostdcall] boolean collapsed();
void collapseNative( in nsINode parentNode, in long offset );
parentNode
offset
collapseToEnd()
Collapses the whole selection to a single point at the end of the current selection (regardless of direction). If content is focused and editable, the caret will blink there.
void collapseToEnd();
None
Collapses the whole selection to a single point at the start of the current selection (regardless of direction). If content is focused and editable, the caret will blink there.
void collapseToStart();
Indicates whether the nsIDOMNode is part of the selection. If partlyContained is set to PR_TRUE, the function returns true
when some part of the node is part of the selection. If partlyContained is set to PR_FALSE, the function only returns true
when the entire node is part of the selection.
boolean containsNode( in nsIDOMNode node, in boolean partlyContained );
node
partlyContained
true
when the entire node is part of the selection.Whether or not the range contains the requested noe.
Deletes this selection from the document the nodes belong to.
void deleteFromDocument();
Extends the selection by moving the selection end to the specified nsIDOMNode and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode
to the new focusNode
, regardless of direction.
void extend( in nsIDOMNode parentNode, in long offset );
parentNode
offset
void extendNative( in nsINode parentNode, in long offset );
parentNode
offset
getRangeAt()
Returns the nsIDOMRange at the specified index.
nsIDOMRange getRangeAt( in long index );
index
The nsIDOMRange requested
Modifies the selection. Note that the parameters are case-insensitive.
void modify( in DOMString alter, in DOMString direction, in DOMString granularity );
alter
extend()
" }
collapsed()
selection.extend()
" leaves the start of the selection unchanged, and applies movement direction/granularity to the end of the selection.direction
granularity
Removes all nsIDOMRanges from the current selection.
void removeAllRanges();
None
Removes a range from the current selection.
void removeRange( in nsIDOMRange range );
range
Adds all children of the specified node to the selection.
void selectAllChildren( in nsIDOMNode parentNode );
parentNode
Modifies the cursor Bidi level after a change in keyboard direction.
void selectionLanguageChange( in boolean langRTL );
langRTL
Returns the whole selection into a plain text string.
DOMString toString();