Help Center

Local Navigation

Object: Selection

Availability

BlackBerry® Device Software version 4.7.1 or later

The Selection object contains one or more Range objects.

Selection properties

Property name

Type

Description

Status

Availability

anchorNode

Node

Returns the node in which the selection begins.

read-only

4.7.1 or later

anchorOffset

int

Returns the number of characters within the anchorNode that the selection begins.

read-only

4.7.1 or later

focusNode

Node

Returns the node in which the selection ends.

read-only

4.7.1 or later

focusOffset

int

Returns the number of characters within the focusNode that the selection ends.

read-only

4.7.1 or later

isCollapsed

boolean

Returns true if the start point and end point of the selection are at the same position; returns false if they are not.

read-only

4.7.1 or later

rangeCount

int

Returns the number of Range objects contained by the Selection object.

read-only

4.7.1 or later

Selection methods

Method name

Description

Support level

Availability

addRange()

Adds a Range object to the selection.

Not part of any standard.

4.7.1 or later

collapse()

Collapses a selection onto a single boundary point.

Not part of any standard.

4.7.1 or later

collapseToEnd()

Moves the anchor of the selection to the same point as the focus.

Not part of any standard.

4.7.1 or later

collapseToStart()

Moves the focus of the selection to the same point as the anchor.

Not part of any standard.

4.7.1 or later

deleteFromDocument()

Deletes the text contained within the selection from the Document object.

Not part of any standard.

4.7.1 or later

getRangeAt()

Returns a Range object that is present in the selection.

Not part of any standard.

4.7.1 or later

removeRange()

Removes the specified Range object from the selection.

Not part of any standard.

4.7.1 or later

removeAllRanges()

Removes all Range objects from the selection.

Not part of any standard.

4.7.1 or later

selectAllChildren()

Adds all the child nodes of a specified node to the selection.

Not part of any standard.

4.7.1 or later

Method: Selection.addRange()

Availability

BlackBerry® Device Software version 4.7.1 or later

The addRange() method adds a Range object to the selection.

Syntax

Selection.addRange( range )

Parameters

Parameter

Type

Description

range

Range

Specifies the Range to add to the selection.

Return values

None.

Exceptions

None.

Method: Selection.collapseToEnd()

Availability

BlackBerry® Device Software version 4.7.1 or later

The collapseToEnd() method moves the anchor of the selection to the same point as the focus.

Syntax

Selection.collapseToEnd()

Parameters

None.

Return values

None.

Exceptions

None.

Method: Selection.collapseToStart()

Availability

BlackBerry® Device Software version 4.7.1 or later

The collapseToStart() method moves the focus of the selection to the same point as the anchor.

Syntax

Selection.collapseToStart()

Parameters

None.

Return values

None.

Exceptions

None.

Method: Selection.collapse()

Availability

BlackBerry® Device Software version 4.7.1 or later

The collapse() method collapses a selection onto a single point.

Syntax

Selection.collapse( parentNode, offset )

Parameters

Parameter

Type

Description

parentNode

Node

Specifies the node into which the selection is collapsed.

offset

int

Specifies the offset to which the selection is collapsed. Valid values may be one of the following:

0: Collapses the selection from the anchor onto the start point of parentNode.

1: Collapses the selection from the anchor onto the end point of parentNode.

Return values

None.

Exceptions

None.

Method: Selection.deleteFromDocument()

Availability

BlackBerry® Device Software version 4.7.1 or later

The deleteFromDocument() method deletes the text contained within the selection from the Document object.

Syntax

Selection.deleteFromDocument()

Parameters

None.

Return values

None.

Exceptions

None.

Method: Selection.getRangeAt()

Availability

BlackBerry® Device Software version 4.7.1 or later

The getRangeAt() method returns a Range object that is present in the selection.

Syntax

Selection.getRangeAt( index )

Parameters

Parameter

Type

Description

index

int

Specifies an integer that represents the Range object’s position in the frame map. Valid values are from 0 to Selection.rangeCount-1.

Return values

This method returns the Range object at the specified index.

Exceptions

None.

Method: Selection.removeAllRanges()

Availability

BlackBerry® Device Software version 4.7.1 or later

The removeAllRanges() method removes all Range objects from the selection.

Syntax

Selection.removeAllRanges()

Parameters

None.

Return values

None.

Exceptions

None.

Method: Selection.removeRange()

Availability

BlackBerry® Device Software version 4.7.1 or later

The removeRange() method removes the specified Range object from the selection.

Syntax

Selection.removeRange( range )

Parameters

Parameter

Type

Description

range

Range

Specifies the Range object to remove from the selection.

Return values

None.

Exceptions

None.

Method: Selection.selectAllChildren()

Availability

BlackBerry® Device Software version 4.7.1 or later

The selectAllChildren() method adds all the child nodes from a specified node to the selection. If the selection is already populated, the contents are replaced.

Syntax

Selection.selectAllChildren( parentNode )

Parameters

Parameter

Type

Description

parentNode

Node

Specifies the node that is the parent of the nodes to add to the selection. The parentNode is not added.

Return values

None.

Exceptions

None.

Next topic: Object: Window
Previous topic: Screen properties

Was this information helpful? Send us your comments.