Skip to content

Gtk.AccessibleText

interface

An interface for accessible objects containing formatted text.

The GtkAccessibleText interfaces is meant to be implemented by accessible objects that have text formatted with attributes, or non-trivial text contents.

You should use the AccessibleProperty.LABEL or the AccessibleProperty.DESCRIPTION properties for accessible objects containing simple, unformatted text.

Methods

update_caret_position

def update_caret_position(self) -> None

Updates the position of the caret.

Implementations of the GtkAccessibleText interface should call this function every time the caret has moved, in order to notify assistive technologies.

update_contents

def update_contents(self, change: AccessibleTextContentChange | int, start: int, end: int) -> None

Notifies assistive technologies of a change in contents.

Implementations of the GtkAccessibleText interface should call this function every time their contents change as the result of an operation, like an insertion or a removal.

Note: If the change is a deletion, this function must be called before removing the contents, if it is an insertion, it must be called after inserting the new contents.

Parameters:

  • change — the type of change in the contents
  • start — the starting offset of the change, in characters
  • end — the end offset of the change, in characters

update_selection_bound

def update_selection_bound(self) -> None

Updates the boundary of the selection.

Implementations of the GtkAccessibleText interface should call this function every time the selection has moved, in order to notify assistive technologies.

Virtual methods

do_get_attributes

def do_get_attributes(self, offset: int) -> tuple[bool, list[AccessibleTextRange], list[str], list[str]]

Retrieves the text attributes inside the accessible object.

Each attribute is composed by:

  • a range
  • a name
  • a value

It is left to the implementation to determine the serialization format of the value to a string.

GTK provides support for various text attribute names and values, but implementations of this interface are free to add their own attributes.

If this function returns true, n_ranges will be set to a value greater than or equal to one, ranges will be set to a newly allocated array of [structGtk.AccessibleTextRange].

Parameters:

  • offset — the offset, in characters

do_get_caret_position

def do_get_caret_position(self) -> int

Retrieves the position of the caret inside the accessible object.

do_get_contents

def do_get_contents(self, start: int, end: int) -> bytes

Retrieve the current contents of the accessible object within the given range.

If end is G_MAXUINT, the end of the range is the full content of the accessible object.

Parameters:

  • start — the beginning of the range, in characters
  • end — the end of the range, in characters

do_get_contents_at

def do_get_contents_at(self, offset: int, granularity: AccessibleTextGranularity | int) -> tuple[bytes, int, int]

Retrieve the current contents of the accessible object starting from the given offset, and using the given granularity.

The start and end values contain the boundaries of the text.

Parameters:

  • offset — the offset, in characters
  • granularity — the granularity of the query

do_get_default_attributes

def do_get_default_attributes(self) -> tuple[list[str], list[str]]

Retrieves the default text attributes inside the accessible object.

Each attribute is composed by:

  • a name
  • a value

It is left to the implementation to determine the serialization format of the value to a string.

GTK provides support for various text attribute names and values, but implementations of this interface are free to add their own attributes.

do_get_extents

def do_get_extents(self, start: int, end: int, extents: Graphene.Rect) -> bool

Obtains the extents of a range of text, in widget coordinates.

Parameters:

  • start — the start offset, in characters
  • end — the end offset, in characters, extents (out caller-allocates): return location for the extents

do_get_offset

def do_get_offset(self, point: Graphene.Point) -> tuple[bool, int]

Gets the text offset at a given point.

Parameters:

  • point — a point in widget coordinates of self

do_get_selection

def do_get_selection(self) -> tuple[bool, list[AccessibleTextRange]]

Retrieves the selection ranges in the accessible object.

If this function returns true, n_ranges will be set to a value greater than or equal to one, and ranges will be set to a newly allocated array of [structGtk.AccessibleTextRange].

do_set_caret_position

def do_set_caret_position(self, offset: int) -> bool

Sets the caret position.

Parameters:

  • offset — the text offset in characters

do_set_selection

def do_set_selection(self, i: int, range: AccessibleTextRange) -> bool

Sets the caret position.

Parameters:

  • i — the selection to set
  • range — the range to set the selection to