IAccessible2 API  Version 1.3
Public Member Functions | List of all members
IAccessibleText Interface Reference

This interface gives read-only access to text. More...

import "AccessibleText.idl";

Inheritance diagram for IAccessibleText:
IAccessibleHypertext IAccessibleText2 IAccessibleHypertext2

Public Member Functions

HRESULT addSelection ([in] long startOffset,[in] long endOffset)
 Adds a text selection. More...
 
HRESULT attributes ([in] long offset,[out] long *startOffset,[out] long *endOffset,[out, retval] BSTR *textAttributes)
 Returns text attributes. More...
 
HRESULT caretOffset ([out, retval] long *offset)
 Returns the position of the caret. More...
 
HRESULT characterExtents ([in] long offset,[in] enum IA2CoordinateType coordType,[out] long *x,[out] long *y,[out] long *width,[out, retval] long *height)
 Returns the bounding box of the specified position. More...
 
HRESULT nSelections ([out, retval] long *nSelections)
 Returns the number of active non-contiguous selections. More...
 
HRESULT offsetAtPoint ([in] long x,[in] long y,[in] enum IA2CoordinateType coordType,[out, retval] long *offset)
 Returns the text position for the specified screen position. More...
 
HRESULT selection ([in] long selectionIndex,[out] long *startOffset,[out, retval] long *endOffset)
 Returns the character offsets of Nth active text selection. More...
 
HRESULT text ([in] long startOffset,[in] long endOffset,[out, retval] BSTR *text)
 Returns the substring between the two given indices. More...
 
HRESULT textBeforeOffset ([in] long offset,[in] enum IA2TextBoundaryType boundaryType,[out] long *startOffset,[out] long *endOffset,[out, retval] BSTR *text)
 Returns a text portion before the given position. More...
 
HRESULT textAfterOffset ([in] long offset,[in] enum IA2TextBoundaryType boundaryType,[out] long *startOffset,[out] long *endOffset,[out, retval] BSTR *text)
 Returns a text portion after the given position. More...
 
HRESULT textAtOffset ([in] long offset,[in] enum IA2TextBoundaryType boundaryType,[out] long *startOffset,[out] long *endOffset,[out, retval] BSTR *text)
 Returns a text portion that spans the given position. More...
 
HRESULT removeSelection ([in] long selectionIndex)
 Unselects a range of text. More...
 
HRESULT setCaretOffset ([in] long offset)
 Sets the position of the caret. More...
 
HRESULT setSelection ([in] long selectionIndex,[in] long startOffset,[in] long endOffset)
 Changes the bounds of an existing selection. More...
 
HRESULT nCharacters ([out, retval] long *nCharacters)
 Returns total number of characters. More...
 
HRESULT scrollSubstringTo ([in] long startIndex,[in] long endIndex,[in] enum IA2ScrollType scrollType)
 Makes a specific part of string visible on screen. More...
 
HRESULT scrollSubstringToPoint ([in] long startIndex,[in] long endIndex,[in] enum IA2CoordinateType coordinateType,[in] long x,[in] long y)
 Moves the top left of a substring to a specified location. More...
 
HRESULT newText ([out, retval] IA2TextSegment *newText)
 Returns any inserted text. More...
 
HRESULT oldText ([out, retval] IA2TextSegment *oldText)
 Returns any removed text. More...
 

Detailed Description

This interface gives read-only access to text.

The IAccessibleText interface should be implemented by all components that present textual information on the display like buttons, text entry fields, or text portions of the document window. The interface provides access to the text's content, attributes, and spatial location. However, text can not be modified with this interface. That is the task of the IAccessibleEditableText interface.

The text length, i.e. the number of characters in the text, is returned by IAccessibleText::nCharacters. All methods that operate on particular characters (e.g. IAccessibleText::textAtOffset) use character indices from 0 to length-1. All methods that operate on character positions (e.g. IAccessibleText::text) use indices from 0 to length.

Please note that accessible text does not necessarily support selection. In this case it should behave as if there where no selection. An empty selection is used for example to express the current cursor position.

Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.

E_FAIL is returned in the following cases

Member Function Documentation

HRESULT IAccessibleText::addSelection ( [in] long  startOffset,
[in] long  endOffset 
)

Adds a text selection.

Parameters
[in]startOffsetStarting offset ( 0 based).
[in]endOffsetOffset of first character after new selection (0 based).
Return values
S_OK
E_INVALIDARGif bad [in] passed
Note
Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
HRESULT IAccessibleText::attributes ( [in] long  offset,
[out] long *  startOffset,
[out] long *  endOffset,
[out, retval] BSTR *  textAttributes 
)
get

Returns text attributes.

Parameters
[in]offsetText offset (0 based). Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
[out]startOffsetThe starting offset of the character range over which all text attributes match those of offset. (0 based)
[out]endOffsetThe offset of the first character past the character range over which all text attributes match those of offset. (0 based)
[out]textAttributesA string of attributes describing the text. The attributes are described in the text attributes specification on the IAccessible2 web site.
Return values
S_OK
S_FALSEif there is nothing to return, [out] values are 0s and NULL respectively
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::caretOffset ( [out, retval] long *  offset)
get

Returns the position of the caret.

Returns the 0-based offset of the caret within the text. If the text is implemented as a tree of text objects with embed characters in higher levels representing substrings of child text objects and the caret is in one of the child text objects, then the offset in the higher level text object would be at the embed character representing child text object that contains the caret.

For example, if the string "one two three" is implemented as a two text objects, with a top level text object containing an embed character "one ? three" and a child text object containing "two" and if the caret is in the descendant object just before the 'o' in "two", then:

  • the caretOffset for the "one ? three" object would be 4, matching the embed character
  • the caretOffset for "two" would be 2, matching the "o"

The caret position/offset is that of the character logically following it, e.g. to the right of it in a left to right language, or to the left of it in a right to left language.

Parameters
[out]offsetThe returned offset is relative to the text represented by this object.
Return values
S_OK
S_FALSEif the caret is not currently active on this object, i.e. the caret is located on some other object. The returned offset value will be -1.
Note
S_FALSE (and an offset of -1) will not be returned if the caret is somewhere in the text object or one of its descendants.
HRESULT IAccessibleText::characterExtents ( [in] long  offset,
[in] enum IA2CoordinateType  coordType,
[out] long *  x,
[out] long *  y,
[out] long *  width,
[out, retval] long *  height 
)
get

Returns the bounding box of the specified position.

The virtual character after the last character of the represented text, i.e. the one at position length is a special case. It represents the current input position and will therefore typically be queried by AT more often than other positions. Because it does not represent an existing character its bounding box is defined in relation to preceding characters. It should be roughly equivalent to the bounding box of some character when inserted at the end of the text. Its height typically being the maximal height of all the characters in the text or the height of the preceding character, its width being at least one pixel so that the bounding box is not degenerate.

Note that the index 'length' is not always valid. Whether it is or not is implementation dependent. It typically is when text is editable or otherwise when on the screen the caret can be placed behind the text. You can be sure that the index is valid after you have received a IA2_EVENT_TEXT_CARET_MOVED event for this index.

Parameters
[in]offsetIndex of the character for which to return its bounding box. The valid range is 0..length. Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
[in]coordTypeSpecifies if the coordinates are relative to the screen or to the parent window.
[out]xX coordinate of the top left corner of the bounding box of the referenced character.
[out]yY coordinate of the top left corner of the bounding box of the referenced character.
[out]widthWidth of the bounding box of the referenced character.
[out]heightHeight of the bounding box of the referenced character.
Return values
S_OK
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::nCharacters ( [out, retval] long *  nCharacters)
get

Returns total number of characters.

Note that this may be different than the total number of bytes required to store the text, if the text contains multi-byte characters.

Parameters
[out]nCharacters
Return values
S_OK
HRESULT IAccessibleText::newText ( [out, retval] IA2TextSegment newText)
get

Returns any inserted text.

Provided for use by the IA2_EVENT_TEXT_INSERTED and IA2_EVENT_TEXT_UPDATED event handlers.

This data is only guaranteed to be valid while the thread notifying the event continues. Once the handler has returned, the validity of the data depends on how the server manages the life cycle of its objects. Also, note that the server may have different life cycle management strategies for controls depending on whether or not a control manages its children. Lists, trees, and tables can have a large number of children and thus it's possible that the child objects for those controls would only be created as needed. Servers should document their life cycle strategy as this will be of interest to assistive technology or script engines accessing data out of process or from other threads. Servers only need to save the last inserted block of text and a scope of the entire application is adequate.

Parameters
[out]newTextThe text that was just inserted.
Return values
S_OK
S_FALSEIf there is nothing to return, the values of IA2TextSegment struct are set as follows: text = NULL, start = 0, end = 0.
HRESULT IAccessibleText::nSelections ( [out, retval] long *  nSelections)
get

Returns the number of active non-contiguous selections.

Parameters
[out]nSelections
Return values
S_OK
HRESULT IAccessibleText::offsetAtPoint ( [in] long  x,
[in] long  y,
[in] enum IA2CoordinateType  coordType,
[out, retval] long *  offset 
)
get

Returns the text position for the specified screen position.

Given a point return the zero-based index of the character under that point. The same functionality could be achieved by using the bounding boxes for each character as returned by IAccessibleText::characterExtents. The method IAccessibleText::offsetAtPoint, however, can be implemented more efficiently.

Parameters
[in]xThe position's x value for which to look up the index of the character that is rendered on to the display at that point.
[in]yThe position's y value for which to look up the index of the character that is rendered on to the display at that point.
[in]coordTypeScreen coordinates or window coordinates.
[out]offsetIndex of the character under the given point or -1 if the point is invalid or there is no character under the point.
Return values
S_OK
S_FALSEif nothing to return, [out] value is -1
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::oldText ( [out, retval] IA2TextSegment oldText)
get

Returns any removed text.

Provided for use by the IA2_EVENT_TEXT_REMOVED/UPDATED event handlers.

This data is only guaranteed to be valid while the thread notifying the event continues. Once the handler has returned, the validity of the data depends on how the server manages the life cycle of its objects. Also, note that the server may have different life cycle management strategies for controls depending on whether or not a control manages its children. Lists, trees, and tables can have a large number of children and thus it's possible that the child objects for those controls would only be created as needed. Servers should document their life cycle strategy as this will be of interest to assistive technology or script engines accessing data out of process or from other threads. Servers only need to save the last removed block of text and a scope of the entire application is adequate.

Parameters
[out]oldTextThe text that was just removed.
Return values
S_OK
S_FALSEIf there is nothing to return, the values of IA2TextSegment struct are set as follows: text = NULL, start = 0, end = 0.
HRESULT IAccessibleText::removeSelection ( [in] long  selectionIndex)

Unselects a range of text.

Parameters
[in]selectionIndexIndex of selection to remove (0 based).
Return values
S_OK
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::scrollSubstringTo ( [in] long  startIndex,
[in] long  endIndex,
[in] enum IA2ScrollType  scrollType 
)

Makes a specific part of string visible on screen.

Parameters
[in]startIndex0 based character offset.
[in]endIndex0 based character offset - the offset of the character just past the last character of the string.
[in]scrollTypeDefines where the object should be placed on the screen.
Return values
S_OK
E_INVALIDARGif bad [in] passed
Note
Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
HRESULT IAccessibleText::scrollSubstringToPoint ( [in] long  startIndex,
[in] long  endIndex,
[in] enum IA2CoordinateType  coordinateType,
[in] long  x,
[in] long  y 
)

Moves the top left of a substring to a specified location.

Parameters
[in]startIndex0 based character offset.
[in]endIndex0 based character offset - the offset of the character just past the last character of the string.
[in]coordinateTypeSpecifies whether the coordinates are relative to the screen or the parent object.
[in]xDefines the x coordinate.
[in]yDefines the y coordinate.
Return values
S_OK
S_FALSEif the object is already at the specified location.
E_INVALIDARGif bad [in] passed
Note
Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
HRESULT IAccessibleText::selection ( [in] long  selectionIndex,
[out] long *  startOffset,
[out, retval] long *  endOffset 
)
get

Returns the character offsets of Nth active text selection.

Returns the 0-based starting and ending offsets of the Nth selection. If the text is implemented as a tree of text objects with embed characters in higher levels representing substrings of child text objects, consider the following. If the starting selection offset is in one of the child text objects, then the starting offset in the higher level text object would be at the embed character representing the child text object that contains the starting selection offset. If the ending selection offset is in one of the child text objects, then the ending offset in the higher level text object would be just after the embed character representing the child text object that contains the ending selection offset.

For example, if the string "one two three" is implemented as a two text objects, with a top level text object containing an embed character "one ? three" and a child text object containing "two" and if the selection is the string "two" then:

  • the startOffset for the "one ? three" object would be 4, matching the embed character and the endOffset would be 5.
  • the startOffset for the "two" object would be 0, and the endOffset would be 3

Selection offsets are that of the character logically following it, e.g. to the right of it in a left to right language or to the left of it in a right to left language.

Parameters
[in]selectionIndexIndex of selection (0 based).
[out]startOffset0 based offset of first selected character
[out]endOffset0 based offset of one past the last selected character.
Return values
S_OK
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::setCaretOffset ( [in] long  offset)

Sets the position of the caret.

The caret position/offset is that of the character logically following it, e.g. to the right of it in a left to right language.

Setting the caret position may or may not alter the current selection. A change of the selection is notified to the accessibility event listeners with an IA2_EVENT_TEXT_SELECTION_CHANGED event.

When the new caret position differs from the old one (which, of course, is the standard case) this is notified to the accessibility event listeners with an IA2_EVENT_TEXT_CARET_MOVED event.

Parameters
[in]offsetThe new index of the caret. This caret is actually placed to the left side of the character with that index. An index of 0 places the caret so that the next insertion goes before the first character. An index of IAccessibleText::nCharacters leads to insertion after the last character. Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
Return values
S_OK
E_FAILif the caret cannot be set
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::setSelection ( [in] long  selectionIndex,
[in] long  startOffset,
[in] long  endOffset 
)

Changes the bounds of an existing selection.

Parameters
[in]selectionIndexIndex of selection to change (0 based)
[in]startOffsetNew starting offset (0 based)
[in]endOffsetNew ending offset (0 based) - the offset of the character just past the last character of the selection.
Return values
S_OK
E_INVALIDARGif bad [in] passed
Note
Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
HRESULT IAccessibleText::text ( [in] long  startOffset,
[in] long  endOffset,
[out, retval] BSTR *  text 
)
get

Returns the substring between the two given indices.

The substring starts with the character at startOffset (inclusive) and up to the character at endOffset (exclusive), if startOffset is less or equal endOffset. If endOffset is lower than startOffset, the result is the same as a call with the two arguments being exchanged.

The whole text can be requested by passing the indices zero and IAccessibleText::nCharacters. If both indices have the same value, an empty string is returned.

Parameters
[in]startOffsetIndex of the first character to include in the returned string. The valid range is 0..length.
[in]endOffsetIndex of the last character to exclude in the returned string. The valid range is 0..length.
[out]textReturns the substring starting with the character at startOffset (inclusive) and up to the character at endOffset (exclusive), if startOffset is less than or equal to endOffset.
Return values
S_OK
E_INVALIDARGif bad [in] passed
Note
HRESULT IAccessibleText::textAfterOffset ( [in] long  offset,
[in] enum IA2TextBoundaryType  boundaryType,
[out] long *  startOffset,
[out] long *  endOffset,
[out, retval] BSTR *  text 
)
get

Returns a text portion after the given position.

Returns the substring of the specified text type that is located after the given character and does not include it. The result of this method should be same as a result for IAccessibleText::textAtOffset with a suitably increased index value.

For example, if text type is IA2_TEXT_BOUNDARY_WORD, then the complete word that is closest to and located after offset is returned.

If the index is valid, but no text is found, S_FALSE is returned along with out values of 0, 0, and a NULL pointer. This would happen for boundary types other than character when the text consists entirely of whitespace.

Parameters
[in]offsetIndex of the character for which to return the text part after it. The index character will not be part of the returned string. The valid range is 0..length. Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
[in]boundaryTypeThe type of the text portion to return. See IA2TextBoundaryType for the complete list.
[out]startOffset0 based offset of first character.
[out]endOffset0 based offset of one past the last character.
[out]textReturns the requested text portion. This portion may be empty or invalid when no appropriate text portion is found or text type is invalid.
Return values
S_OK
S_FALSEif the requested boundary type is not implemented, such as IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; [out] values are 0s and NULL respectively
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::textAtOffset ( [in] long  offset,
[in] enum IA2TextBoundaryType  boundaryType,
[out] long *  startOffset,
[out] long *  endOffset,
[out, retval] BSTR *  text 
)
get

Returns a text portion that spans the given position.

Returns the substring defined by the specified boundary type at the specified offset. Refer to IA2TextBoundaryType for more details.

For the word boundary type the returned string will contain the word at the offset if the offset is inside a word and will contain the word before the offset if the offset is not inside a word. All offsets from the first to the last characters of a word are considered inside the word. Boundary types of sentence and paragraph should exhibit similar behavior.

If the index is valid, but no text is found, S_FALSE is returned along with out values of 0, 0, and a NULL pointer. This would happen for boundary types other than character when the text consists entirely of whitespace.

Parameters
[in]offsetIndex of the character for which to return the text part it belongs to. The valid range is 0..length. Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
[in]boundaryTypeThe type of the text portion to return. See IA2TextBoundaryType for the complete list.
[out]startOffset0 based offset of first character.
[out]endOffset0 based offset of one past the last character.
[out]textReturns the requested text portion. This portion may be empty or invalid when no appropriate text portion is found or text type is invalid.
Return values
S_OK
S_FALSEif the requested boundary type is not implemented, such as IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; [out] values are 0s and NULL respectively
E_INVALIDARGif bad [in] passed
HRESULT IAccessibleText::textBeforeOffset ( [in] long  offset,
[in] enum IA2TextBoundaryType  boundaryType,
[out] long *  startOffset,
[out] long *  endOffset,
[out, retval] BSTR *  text 
)
get

Returns a text portion before the given position.

Returns the substring of the specified text type that is located before the given character and does not include it. The result of this method should be same as a result for IAccessibleText::textAtOffset with a suitably decreased index value.

For example, if text type is IA2_TEXT_BOUNDARY_WORD, then the complete word that is closest to and located before offset is returned.

If the index is valid, but no text is found, S_FALSE is returned along with out values of 0, 0, and a NULL pointer. This would happen for boundary types other than character when the text consists entirely of whitespace.

Parameters
[in]offsetIndex of the character for which to return the text part before it. The index character will not be part of the returned string. The valid range is 0..length. Refer to Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods for information about special offsets that can be used in IAccessibleText methods.
[in]boundaryTypeThe type of the text portion to return. See IA2TextBoundaryType for the complete list.
[out]startOffset0 based offset of first character.
[out]endOffset0 based offset of one past the last character.
[out]textReturns the requested text portion. This portion may be empty or invalid when no appropriate text portion is found or text type is invalid.
Return values
S_OK
S_FALSEif the requested boundary type is not implemented, such as IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; [out] values are 0s and NULL respectively
E_INVALIDARGif bad [in] passed

The documentation for this interface was generated from the following file:
Generated on Wed Jul 10 2013 09:47:26 for IAccessible2 API Version 1.3 by  doxygen 1.8.3.1