Atk.Text

g Atk.Text Atk.Text GObject.GInterface GObject.GInterface GObject.GInterface->Atk.Text

Implementations:

Atk.NoOpObject

Methods

class

free_ranges (ranges)

add_selection (start_offset, end_offset)

get_bounded_ranges (rect, coord_type, x_clip_type, y_clip_type)

get_caret_offset ()

get_character_at_offset (offset)

get_character_count ()

get_character_extents (offset, coords)

get_default_attributes ()

get_n_selections ()

get_offset_at_point (x, y, coords)

get_range_extents (start_offset, end_offset, coord_type)

get_run_attributes (offset)

get_selection (selection_num)

get_string_at_offset (offset, granularity)

get_text (start_offset, end_offset)

get_text_after_offset (offset, boundary_type)

get_text_at_offset (offset, boundary_type)

get_text_before_offset (offset, boundary_type)

remove_selection (selection_num)

scroll_substring_to (start_offset, end_offset, type)

scroll_substring_to_point (start_offset, end_offset, coords, x, y)

set_caret_offset (offset)

set_selection (selection_num, start_offset, end_offset)

Virtual Methods

do_add_selection (start_offset, end_offset)

do_get_bounded_ranges (rect, coord_type, x_clip_type, y_clip_type)

do_get_caret_offset ()

do_get_character_at_offset (offset)

do_get_character_count ()

do_get_character_extents (offset, coords)

do_get_default_attributes ()

do_get_n_selections ()

do_get_offset_at_point (x, y, coords)

do_get_range_extents (start_offset, end_offset, coord_type)

do_get_run_attributes (offset)

do_get_selection (selection_num)

do_get_string_at_offset (offset, granularity)

do_get_text (start_offset, end_offset)

do_get_text_after_offset (offset, boundary_type)

do_get_text_at_offset (offset, boundary_type)

do_get_text_before_offset (offset, boundary_type)

do_remove_selection (selection_num)

do_scroll_substring_to (start_offset, end_offset, type)

do_scroll_substring_to_point (start_offset, end_offset, coords, x, y)

do_set_caret_offset (offset)

do_set_selection (selection_num, start_offset, end_offset)

do_text_attributes_changed ()

do_text_caret_moved (location)

do_text_changed (position, length)

do_text_selection_changed ()

Properties

None

Signals

Name

Short Description

text-attributes-changed

The “text-attributes-changed” signal is emitted when the text attributes of the text of an object which implements Atk.Text changes.

text-caret-moved

The “text-caret-moved” signal is emitted when the caret position of the text of an object which implements Atk.Text changes.

text-changed

The “text-changed” signal is emitted when the text of the object which implements the Atk.Text interface changes, This signal will have a detail which is either “insert” or “delete” which identifies whether the text change was an insertion or a deletion. deprecated

text-insert

The “text-insert” signal is emitted when a new text is inserted.

text-remove

The “text-remove” signal is emitted when a new text is removed.

text-selection-changed

The “text-selection-changed” signal is emitted when the selected text of an object which implements Atk.Text changes.

Fields

None

Class Details

class Atk.Text
Bases:

GObject.GInterface

Structure:

Atk.TextIface

The ATK interface implemented by components with text content.

Atk.Text should be implemented by Atk.Objects on behalf of widgets that have text content which is either attributed or otherwise non-trivial. Atk.Objects whose text content is simple, unattributed, and very brief may expose that content via Atk.Object.get_name instead; however if the text is editable, multi-line, typically longer than three or four words, attributed, selectable, or if the object already uses the ‘name’ ATK property for other information, the Atk.Text interface should be used to expose the text content. In the case of editable text content, Atk.EditableText (a subtype of the Atk.Text interface) should be implemented instead.

Atk.Text provides not only traversal facilities and change notification for text content, but also caret tracking and glyph bounding box calculations. Note that the text strings are exposed as UTF-8, and are therefore potentially multi-byte, and caret-to-byte offset mapping makes no assumptions about the character length; also bounding box glyph-to-offset mapping may be complex for languages which use ligatures.

classmethod free_ranges(ranges)[source]
Parameters:

ranges ([Atk.TextRange]) – A pointer to an array of Atk.TextRange which is to be freed.

Frees the memory associated with an array of Atk.TextRange. It is assumed that the array was returned by the function Atk.Text.get_bounded_ranges and is None terminated.

New in version 1.3.

add_selection(start_offset, end_offset)[source]
Parameters:
  • start_offset (int) – the starting character offset of the selected region

  • end_offset (int) – the offset of the first character after the selected region.

Returns:

True if successful, False otherwise

Return type:

bool

Adds a selection bounded by the specified offsets.

get_bounded_ranges(rect, coord_type, x_clip_type, y_clip_type)[source]
Parameters:
Returns:

Array of Atk.TextRange. The last element of the array returned by this function will be None.

Return type:

[Atk.TextRange]

Get the ranges of text in the specified bounding box.

New in version 1.3.

get_caret_offset()[source]
Returns:

the character offset of the position of the caret or -1 if the caret is not located inside the element or in the case of any other failure.

Return type:

int

Gets the offset of the position of the caret (cursor).

get_character_at_offset(offset)[source]
Parameters:

offset (int) – a character offset within self

Returns:

the character at offset or 0 in the case of failure.

Return type:

str

Gets the specified text.

get_character_count()[source]
Returns:

the number of characters or -1 in case of failure.

Return type:

int

Gets the character count.

get_character_extents(offset, coords)[source]
Parameters:
  • offset (int) – The offset of the text character for which bounding information is required.

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or widget window

Returns:

x:

Pointer for the x coordinate of the bounding box

y:

Pointer for the y coordinate of the bounding box

width:

Pointer for the width of the bounding box

height:

Pointer for the height of the bounding box

Return type:

(x: int, y: int, width: int, height: int)

If the extent can not be obtained (e.g. missing support), all of x, y, width, height are set to -1.

Get the bounding box containing the glyph representing the character at a particular text offset.

get_default_attributes()[source]
Returns:

an #AtkAttributeSet which contains the default text attributes for this Atk.Text. This #AtkAttributeSet should be freed by a call to Atk.Attribute.set_free().

Return type:

[object]

Creates an #AtkAttributeSet which consists of the default values of attributes for the text. See the enum Atk.TextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.

get_n_selections()[source]
Returns:

The number of selected regions, or -1 in the case of failure.

Return type:

int

Gets the number of selected regions.

get_offset_at_point(x, y, coords)[source]
Parameters:
  • x (int) – screen x-position of character

  • y (int) – screen y-position of character

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or widget window

Returns:

the offset to the character which is located at the specified x and y coordinates of -1 in case of failure.

Return type:

int

Gets the offset of the character located at coordinates x and y. x and y are interpreted as being relative to the screen or this widget’s window depending on coords.

get_range_extents(start_offset, end_offset, coord_type)[source]
Parameters:
  • start_offset (int) – The offset of the first text character for which boundary information is required.

  • end_offset (int) – The offset of the text character after the last character for which boundary information is required.

  • coord_type (Atk.CoordType) – Specify whether coordinates are relative to the screen or widget window.

Returns:

A pointer to a Atk.TextRectangle which is filled in by this function.

Return type:

rect: Atk.TextRectangle

Get the bounding box for text within the specified range.

If the extents can not be obtained (e.g. or missing support), the rectangle fields are set to -1.

New in version 1.3.

get_run_attributes(offset)[source]
Parameters:

offset (int) – the character offset at which to get the attributes, -1 means the offset of the character to be inserted at the caret location.

Returns:

an #AtkAttributeSet which contains the attributes explicitly set at offset. This #AtkAttributeSet should be freed by a call to Atk.Attribute.set_free().

start_offset:

the address to put the start offset of the range

end_offset:

the address to put the end offset of the range

Return type:

([object], start_offset: int, end_offset: int)

Creates an #AtkAttributeSet which consists of the attributes explicitly set at the position offset in the text. start_offset and end_offset are set to the start and end of the range around offset where the attributes are invariant. Note that end_offset is the offset of the first character after the range. See the enum Atk.TextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.

get_selection(selection_num)[source]
Parameters:

selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

Returns:

a newly allocated string containing the selected text. Use GLib.free() to free the returned string.

start_offset:

passes back the starting character offset of the selected region

end_offset:

passes back the ending character offset (offset immediately past) of the selected region

Return type:

(str, start_offset: int, end_offset: int)

Gets the text from the specified selection.

get_string_at_offset(offset, granularity)[source]
Parameters:
Returns:

a newly allocated string containing the text at the offset bounded by the specified granularity. Use GLib.free() to free the returned string. Returns None if the offset is invalid or no implementation is available.

start_offset:

the starting character offset of the returned string, or -1 in the case of error (e.g. invalid offset, not implemented)

end_offset:

the offset of the first character after the returned string, or -1 in the case of error (e.g. invalid offset, not implemented)

Return type:

(str or None, start_offset: int, end_offset: int)

Gets a portion of the text exposed through an Atk.Text according to a given offset and a specific granularity, along with the start and end offsets defining the boundaries of such a portion of text.

If granularity is Atk.TextGranularity.CHAR the character at the offset is returned.

If granularity is Atk.TextGranularity.WORD the returned string is from the word start at or before the offset to the word start after the offset.

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.

If granularity is Atk.TextGranularity.SENTENCE the returned string is from the sentence start at or before the offset to the sentence start after the offset.

The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.

If granularity is Atk.TextGranularity.LINE the returned string is from the line start at or before the offset to the line start after the offset.

If granularity is Atk.TextGranularity.PARAGRAPH the returned string is from the start of the paragraph at or before the offset to the start of the following paragraph after the offset.

New in version 2.10.

get_text(start_offset, end_offset)[source]
Parameters:
  • start_offset (int) – a starting character offset within self

  • end_offset (int) – an ending character offset within self, or -1 for the end of the string.

Returns:

a newly allocated string containing the text from start_offset up to, but not including end_offset. Use GLib.free() to free the returned string.

Return type:

str

Gets the specified text.

get_text_after_offset(offset, boundary_type)[source]
Parameters:
Returns:

a newly allocated string containing the text after offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

Deprecated since version 2.9.3: Please use Atk.Text.get_string_at_offset() instead.

get_text_at_offset(offset, boundary_type)[source]
Parameters:
Returns:

a newly allocated string containing the text at offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

If the boundary_type if Atk.TextBoundary.CHAR the character at the offset is returned.

If the boundary_type is Atk.TextBoundary.WORD_START the returned string is from the word start at or before the offset to the word start after the offset.

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.

If the boundary type is Atk.TextBoundary.SENTENCE_START the returned string is from the sentence start at or before the offset to the sentence start after the offset.

The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.

If the boundary type is Atk.TextBoundary.LINE_START the returned string is from the line start at or before the offset to the line start after the offset.

Deprecated since version ???: This method is deprecated since ATK version 2.9.4. Please use Atk.Text.get_string_at_offset() instead.

get_text_before_offset(offset, boundary_type)[source]
Parameters:
Returns:

a newly allocated string containing the text before offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

Deprecated since version 2.9.3: Please use Atk.Text.get_string_at_offset() instead.

remove_selection(selection_num)[source]
Parameters:

selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

Returns:

True if successful, False otherwise

Return type:

bool

Removes the specified selection.

scroll_substring_to(start_offset, end_offset, type)[source]
Parameters:
  • start_offset (int) – start offset in the self

  • end_offset (int) – end offset in the self, or -1 for the end of the text.

  • type (Atk.ScrollType) – specify where the object should be made visible.

Returns:

whether scrolling was successful.

Return type:

bool

Makes a substring of self visible on the screen by scrolling all necessary parents.

New in version 2.32.

scroll_substring_to_point(start_offset, end_offset, coords, x, y)[source]
Parameters:
  • start_offset (int) – start offset in the self

  • end_offset (int) – end offset in the self, or -1 for the end of the text.

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or to the parent object.

  • x (int) – x-position where to scroll to

  • y (int) – y-position where to scroll to

Returns:

whether scrolling was successful.

Return type:

bool

Move the top-left of a substring of self to a given position of the screen by scrolling all necessary parents.

New in version 2.32.

set_caret_offset(offset)[source]
Parameters:

offset (int) – the character offset of the new caret position

Returns:

True if successful, False otherwise.

Return type:

bool

Sets the caret (cursor) position to the specified offset.

In the case of rich-text content, this method should either grab focus or move the sequential focus navigation starting point (if the application supports this concept) as if the user had clicked on the new caret position. Typically, this means that the target of this operation is the node containing the new caret position or one of its ancestors. In other words, after this method is called, if the user advances focus, it should move to the first focusable node following the new caret position.

Calling this method should also scroll the application viewport in a way that matches the behavior of the application’s typical caret motion or tab navigation as closely as possible. This also means that if the application’s caret motion or focus navigation does not trigger a scroll operation, this method should not trigger one either. If the application does not have a caret motion or focus navigation operation, this method should try to scroll the new caret position into view while minimizing unnecessary scroll motion.

set_selection(selection_num, start_offset, end_offset)[source]
Parameters:
  • selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

  • start_offset (int) – the new starting character offset of the selection

  • end_offset (int) – the new end position of (e.g. offset immediately past) the selection

Returns:

True if successful, False otherwise

Return type:

bool

Changes the start and end offset of the specified selection.

do_add_selection(start_offset, end_offset) virtual
Parameters:
  • start_offset (int) – the starting character offset of the selected region

  • end_offset (int) – the offset of the first character after the selected region.

Returns:

True if successful, False otherwise

Return type:

bool

Adds a selection bounded by the specified offsets.

do_get_bounded_ranges(rect, coord_type, x_clip_type, y_clip_type) virtual
Parameters:
Returns:

Array of Atk.TextRange. The last element of the array returned by this function will be None.

Return type:

[Atk.TextRange]

Get the ranges of text in the specified bounding box.

New in version 1.3.

do_get_caret_offset() virtual
Returns:

the character offset of the position of the caret or -1 if the caret is not located inside the element or in the case of any other failure.

Return type:

int

Gets the offset of the position of the caret (cursor).

do_get_character_at_offset(offset) virtual
Parameters:

offset (int) – a character offset within text

Returns:

the character at offset or 0 in the case of failure.

Return type:

str

Gets the specified text.

do_get_character_count() virtual
Returns:

the number of characters or -1 in case of failure.

Return type:

int

Gets the character count.

do_get_character_extents(offset, coords) virtual
Parameters:
  • offset (int) – The offset of the text character for which bounding information is required.

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or widget window

Returns:

x:

Pointer for the x coordinate of the bounding box

y:

Pointer for the y coordinate of the bounding box

width:

Pointer for the width of the bounding box

height:

Pointer for the height of the bounding box

Return type:

(x: int, y: int, width: int, height: int)

If the extent can not be obtained (e.g. missing support), all of x, y, width, height are set to -1.

Get the bounding box containing the glyph representing the character at a particular text offset.

do_get_default_attributes() virtual
Returns:

an #AtkAttributeSet which contains the default text attributes for this Atk.Text. This #AtkAttributeSet should be freed by a call to Atk.Attribute.set_free().

Return type:

[object]

Creates an #AtkAttributeSet which consists of the default values of attributes for the text. See the enum Atk.TextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.

do_get_n_selections() virtual
Returns:

The number of selected regions, or -1 in the case of failure.

Return type:

int

Gets the number of selected regions.

do_get_offset_at_point(x, y, coords) virtual
Parameters:
  • x (int) – screen x-position of character

  • y (int) – screen y-position of character

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or widget window

Returns:

the offset to the character which is located at the specified x and y coordinates of -1 in case of failure.

Return type:

int

Gets the offset of the character located at coordinates x and y. x and y are interpreted as being relative to the screen or this widget’s window depending on coords.

do_get_range_extents(start_offset, end_offset, coord_type) virtual
Parameters:
  • start_offset (int) – The offset of the first text character for which boundary information is required.

  • end_offset (int) – The offset of the text character after the last character for which boundary information is required.

  • coord_type (Atk.CoordType) – Specify whether coordinates are relative to the screen or widget window.

Returns:

A pointer to a Atk.TextRectangle which is filled in by this function.

Return type:

rect: Atk.TextRectangle

Get the bounding box for text within the specified range.

If the extents can not be obtained (e.g. or missing support), the rectangle fields are set to -1.

New in version 1.3.

do_get_run_attributes(offset) virtual
Parameters:

offset (int) – the character offset at which to get the attributes, -1 means the offset of the character to be inserted at the caret location.

Returns:

an #AtkAttributeSet which contains the attributes explicitly set at offset. This #AtkAttributeSet should be freed by a call to Atk.Attribute.set_free().

start_offset:

the address to put the start offset of the range

end_offset:

the address to put the end offset of the range

Return type:

([object], start_offset: int, end_offset: int)

Creates an #AtkAttributeSet which consists of the attributes explicitly set at the position offset in the text. start_offset and end_offset are set to the start and end of the range around offset where the attributes are invariant. Note that end_offset is the offset of the first character after the range. See the enum Atk.TextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.

do_get_selection(selection_num) virtual
Parameters:

selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

Returns:

a newly allocated string containing the selected text. Use GLib.free() to free the returned string.

start_offset:

passes back the starting character offset of the selected region

end_offset:

passes back the ending character offset (offset immediately past) of the selected region

Return type:

(str, start_offset: int, end_offset: int)

Gets the text from the specified selection.

do_get_string_at_offset(offset, granularity) virtual
Parameters:
Returns:

a newly allocated string containing the text at the offset bounded by the specified granularity. Use GLib.free() to free the returned string. Returns None if the offset is invalid or no implementation is available.

start_offset:

the starting character offset of the returned string, or -1 in the case of error (e.g. invalid offset, not implemented)

end_offset:

the offset of the first character after the returned string, or -1 in the case of error (e.g. invalid offset, not implemented)

Return type:

(str or None, start_offset: int, end_offset: int)

Gets a portion of the text exposed through an Atk.Text according to a given offset and a specific granularity, along with the start and end offsets defining the boundaries of such a portion of text.

If granularity is Atk.TextGranularity.CHAR the character at the offset is returned.

If granularity is Atk.TextGranularity.WORD the returned string is from the word start at or before the offset to the word start after the offset.

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.

If granularity is Atk.TextGranularity.SENTENCE the returned string is from the sentence start at or before the offset to the sentence start after the offset.

The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.

If granularity is Atk.TextGranularity.LINE the returned string is from the line start at or before the offset to the line start after the offset.

If granularity is Atk.TextGranularity.PARAGRAPH the returned string is from the start of the paragraph at or before the offset to the start of the following paragraph after the offset.

New in version 2.10.

do_get_text(start_offset, end_offset) virtual
Parameters:
  • start_offset (int) – a starting character offset within text

  • end_offset (int) – an ending character offset within text, or -1 for the end of the string.

Returns:

a newly allocated string containing the text from start_offset up to, but not including end_offset. Use GLib.free() to free the returned string.

Return type:

str

Gets the specified text.

do_get_text_after_offset(offset, boundary_type) virtual
Parameters:
Returns:

a newly allocated string containing the text after offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

Deprecated since version 2.9.3: Please use Atk.Text.get_string_at_offset() instead.

do_get_text_at_offset(offset, boundary_type) virtual
Parameters:
Returns:

a newly allocated string containing the text at offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

If the boundary_type if Atk.TextBoundary.CHAR the character at the offset is returned.

If the boundary_type is Atk.TextBoundary.WORD_START the returned string is from the word start at or before the offset to the word start after the offset.

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.

If the boundary type is Atk.TextBoundary.SENTENCE_START the returned string is from the sentence start at or before the offset to the sentence start after the offset.

The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.

If the boundary type is Atk.TextBoundary.LINE_START the returned string is from the line start at or before the offset to the line start after the offset.

Deprecated since version ???: This method is deprecated since ATK version 2.9.4. Please use Atk.Text.get_string_at_offset() instead.

do_get_text_before_offset(offset, boundary_type) virtual
Parameters:
Returns:

a newly allocated string containing the text before offset bounded by the specified boundary_type. Use GLib.free() to free the returned string.

start_offset:

the starting character offset of the returned string

end_offset:

the offset of the first character after the returned substring

Return type:

(str, start_offset: int, end_offset: int)

Gets the specified text.

Deprecated since version 2.9.3: Please use Atk.Text.get_string_at_offset() instead.

do_remove_selection(selection_num) virtual
Parameters:

selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

Returns:

True if successful, False otherwise

Return type:

bool

Removes the specified selection.

do_scroll_substring_to(start_offset, end_offset, type) virtual
Parameters:
  • start_offset (int) – start offset in the text

  • end_offset (int) – end offset in the text, or -1 for the end of the text.

  • type (Atk.ScrollType) – specify where the object should be made visible.

Returns:

whether scrolling was successful.

Return type:

bool

Makes a substring of text visible on the screen by scrolling all necessary parents.

New in version 2.32.

do_scroll_substring_to_point(start_offset, end_offset, coords, x, y) virtual
Parameters:
  • start_offset (int) – start offset in the text

  • end_offset (int) – end offset in the text, or -1 for the end of the text.

  • coords (Atk.CoordType) – specify whether coordinates are relative to the screen or to the parent object.

  • x (int) – x-position where to scroll to

  • y (int) – y-position where to scroll to

Returns:

whether scrolling was successful.

Return type:

bool

Move the top-left of a substring of text to a given position of the screen by scrolling all necessary parents.

New in version 2.32.

do_set_caret_offset(offset) virtual
Parameters:

offset (int) – the character offset of the new caret position

Returns:

True if successful, False otherwise.

Return type:

bool

Sets the caret (cursor) position to the specified offset.

In the case of rich-text content, this method should either grab focus or move the sequential focus navigation starting point (if the application supports this concept) as if the user had clicked on the new caret position. Typically, this means that the target of this operation is the node containing the new caret position or one of its ancestors. In other words, after this method is called, if the user advances focus, it should move to the first focusable node following the new caret position.

Calling this method should also scroll the application viewport in a way that matches the behavior of the application’s typical caret motion or tab navigation as closely as possible. This also means that if the application’s caret motion or focus navigation does not trigger a scroll operation, this method should not trigger one either. If the application does not have a caret motion or focus navigation operation, this method should try to scroll the new caret position into view while minimizing unnecessary scroll motion.

do_set_selection(selection_num, start_offset, end_offset) virtual
Parameters:
  • selection_num (int) – The selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.

  • start_offset (int) – the new starting character offset of the selection

  • end_offset (int) – the new end position of (e.g. offset immediately past) the selection

Returns:

True if successful, False otherwise

Return type:

bool

Changes the start and end offset of the specified selection.

do_text_attributes_changed() virtual
do_text_caret_moved(location) virtual
Parameters:

location (int) –

do_text_changed(position, length) virtual
Parameters:
  • position (int) –

  • length (int) –

do_text_selection_changed() virtual

Signal Details

Atk.Text.signals.text_attributes_changed(text)
Signal Name:

text-attributes-changed

Flags:

RUN_LAST

Parameters:

text (Atk.Text) – The object which received the signal

The “text-attributes-changed” signal is emitted when the text attributes of the text of an object which implements Atk.Text changes.

Atk.Text.signals.text_caret_moved(text, arg1)
Signal Name:

text-caret-moved

Flags:

RUN_LAST

Parameters:
  • text (Atk.Text) – The object which received the signal

  • arg1 (int) – The new position of the text caret.

The “text-caret-moved” signal is emitted when the caret position of the text of an object which implements Atk.Text changes.

Atk.Text.signals.text_changed(text, arg1, arg2)
Signal Name:

text-changed

Flags:

RUN_LAST, DETAILED

Parameters:
  • text (Atk.Text) – The object which received the signal

  • arg1 (int) – The position (character offset) of the insertion or deletion.

  • arg2 (int) – The length (in characters) of text inserted or deleted.

The “text-changed” signal is emitted when the text of the object which implements the Atk.Text interface changes, This signal will have a detail which is either “insert” or “delete” which identifies whether the text change was an insertion or a deletion.

Deprecated since version 2.9.4: Use Atk.Object ::text-insert or Atk.Object ::text-remove instead.

Atk.Text.signals.text_insert(text, arg1, arg2, arg3)
Signal Name:

text-insert

Flags:

RUN_LAST, DETAILED

Parameters:
  • text (Atk.Text) – The object which received the signal

  • arg1 (int) – The position (character offset) of the insertion.

  • arg2 (int) – The length (in characters) of text inserted.

  • arg3 (str) – The new text inserted

The “text-insert” signal is emitted when a new text is inserted. If the signal was not triggered by the user (e.g. typing or pasting text), the “system” detail should be included.

Atk.Text.signals.text_remove(text, arg1, arg2, arg3)
Signal Name:

text-remove

Flags:

RUN_LAST, DETAILED

Parameters:
  • text (Atk.Text) – The object which received the signal

  • arg1 (int) – The position (character offset) of the removal.

  • arg2 (int) – The length (in characters) of text removed.

  • arg3 (str) – The old text removed

The “text-remove” signal is emitted when a new text is removed. If the signal was not triggered by the user (e.g. typing or pasting text), the “system” detail should be included.

Atk.Text.signals.text_selection_changed(text)
Signal Name:

text-selection-changed

Flags:

RUN_LAST

Parameters:

text (Atk.Text) – The object which received the signal

The “text-selection-changed” signal is emitted when the selected text of an object which implements Atk.Text changes.