com.xpn.xwiki.wysiwyg.client.selection
Interface Selection

All Known Implementing Classes:
AbstractSelection, DefaultSelection, IESelection

public interface Selection

A selection object represents the ranges that the user has selected, or the cursor position when the user didn't select any range. It is the only was to get access to the current DOM nodes being edited with the WYSIWYG editor.


Method Summary
 void addRange(Range range)
          Adds a range to the current selection.
 void collapse(com.google.gwt.dom.client.Node parentNode, int offset)
          Collapses the selection to a single point, at the specified offset in the given DOM node.
 void collapseToEnd()
          Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).
 void collapseToStart()
          Collapses the whole selection to a single point at the start of the current selection (irrespective of direction).
 boolean containsNode(com.google.gwt.dom.client.Node node, boolean partlyContained)
          Indicates whether the node is part of the selection.
 void deleteFromDocument()
          Deletes this selection from document the nodes belong to.
 void extend(com.google.gwt.dom.client.Node parentNode, int offset)
          Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position.
 com.google.gwt.dom.client.Node getAnchorNode()
           
 int getAnchorOffset()
           
 com.google.gwt.dom.client.Node getFocusNode()
           
 int getFocusOffset()
           
 Range getRangeAt(int index)
           
 int getRangeCount()
           
 boolean isCollapsed()
           
 void removeAllRanges()
          Removes all ranges from the current selection.
 void removeRange(Range range)
          Removes a range from the current selection.
 void selectAllChildren(com.google.gwt.dom.client.Node parentNode)
          Adds all children of the specified node to the selection.
 void selectionLanguageChange(boolean langRTL)
          Modifies the cursor Bidi level after a change in keyboard direction
 java.lang.String toString()
           
 

Method Detail

getAnchorNode

com.google.gwt.dom.client.Node getAnchorNode()
Returns:
The node in which the selection begins.

getAnchorOffset

int getAnchorOffset()
Returns:
The offset within the (text) node where the selection begins.

getFocusNode

com.google.gwt.dom.client.Node getFocusNode()
Returns:
The node in which the selection ends.

getFocusOffset

int getFocusOffset()
Returns:
The offset within the (text) node where the selection ends.

isCollapsed

boolean isCollapsed()
Returns:
true if the selection is collapsed.

getRangeCount

int getRangeCount()
Returns:
The number of ranges in the selection.

getRangeAt

Range getRangeAt(int index)
Returns:
The range at the specified index.

collapse

void collapse(com.google.gwt.dom.client.Node parentNode,
              int 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.

Parameters:
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).

extend

void extend(com.google.gwt.dom.client.Node parentNode,
            int offset)
Extends the selection by moving the selection end to the specified node 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.

Parameters:
parentNode - The node where the selection will be extended to.
offset - Where in node to place the offset in the new selection end.

collapseToStart

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.


collapseToEnd

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.


containsNode

boolean containsNode(com.google.gwt.dom.client.Node node,
                     boolean partlyContained)
Indicates whether the node is part of the selection. If partlyContained is set to true, the function returns true when some part of the node is part of the selection. If partlyContained is set to false, the function only returns true when the entire node is part of the selection.


selectAllChildren

void selectAllChildren(com.google.gwt.dom.client.Node parentNode)
Adds all children of the specified node to the selection.

Parameters:
parentNode - the parent of the children to be added to the selection.

addRange

void addRange(Range range)
Adds a range to the current selection.


removeRange

void removeRange(Range range)
Removes a range from the current selection.


removeAllRanges

void removeAllRanges()
Removes all ranges from the current selection.


deleteFromDocument

void deleteFromDocument()
Deletes this selection from document the nodes belong to.


selectionLanguageChange

void selectionLanguageChange(boolean langRTL)
Modifies the cursor Bidi level after a change in keyboard direction

Parameters:
langRTL - is true if the new language is right-to-left or false if the new language is left-to-right.

toString

java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A string currently being represented by the selection object, i.e. the currently selected text.


Copyright © 2004-2008 XWiki. All Rights Reserved.