Class: ATSPI::Accessible

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Extents, Selectable
Defined in:
lib/atspi/accessible.rb,
lib/atspi/accessible/text.rb,
lib/atspi/accessible/action.rb,
lib/atspi/accessible/extents.rb,
lib/atspi/accessible/document.rb,
lib/atspi/accessible/hyperlink.rb,
lib/atspi/accessible/selectable.rb,
lib/atspi/accessible/table/cells.rb,
lib/atspi/accessible/text/hyperlink.rb

Overview

Wraps libatspi’s AtspiAccessible

The entry point to get ATSPI::Accessibles or one of it sub types are ATSPI.desktops and ATSPI.applications. From there, accessibles are gotten via Tree & Traversal methods like #parent, #children or #descendants.

Most methods correspond directly to the method in libatspi. Some have an extended or beautified interface that is documented here.

Direct Known Subclasses

Table::Cell, Application, Desktop, Window

Defined Under Namespace

Modules: Extents, Selectable Classes: Action, Children, Descendants, Document, Hyperlink, Image, Table, Text, Value

Identification collapse

Attributes & States collapse

Tree & Traversal collapse

Actions collapse

Representative for collapse

Representations collapse

Instance Method Details

#actionsArray<Action>

Returns the actions it supports. The array will be empty if it does not implement the action interface.

Returns:

  • (Array<Action>)

    the actions it supports. The array will be empty if it does not implement the action interface.

See Also:



204
205
206
207
208
209
210
# File 'lib/atspi/accessible.rb', line 204

def actions
  if @native.action_iface
    @native.n_actions.times.map{ |idx| Action.new(@native, idx) }
  else
    []
  end
end

#applicationApplication

Returns its application.

Returns:

See Also:



57
58
59
# File 'lib/atspi/accessible.rb', line 57

def application
  Application.new(@native.application)
end

#attributesHash<String => String>

Returns its attributes.

Returns:

  • (Hash<String => String>)

    its attributes

See Also:



127
128
129
# File 'lib/atspi/accessible.rb', line 127

def attributes
  @native.attributes.to_h
end

#childrenChildren

Returns its children.

Returns:



148
149
150
# File 'lib/atspi/accessible.rb', line 148

def children
  Children.new(@native)
end

#contains?(x, y, relative_to:) ⇒ true, false Originally defined in module Extents

Checks if the given point lies within its bounds

Examples:

accessible.contains?(1243, 323, relative_to: :screen) # => true

Parameters:

  • x (Integer)
  • y (Integer)
  • relative_to (Symbol)

    coordinate system derived from libatspi’s AtspiCoordType enum by removing the prefix ATSPI_COORD_TYPE and making it lowercase

Returns:

  • (true, false)

See Also:

#descendant_at(x, y, relative_to:) ⇒ Accessible? Originally defined in module Extents

Returns the descendant at the given coordinates. nil if it does not implement the component interface.

Examples:

accessible.descendant_at(1243, 323, relative_to: :screen) # => #<ATSPI::Accessible:0x140839014 …>

Parameters:

  • x (Integer)
  • y (Integer)
  • relative_to (Symbol)

    coordinate system derived from libatspi’s AtspiCoordType enum by removing the prefix ATSPI_COORD_TYPE and making it lowercase

Returns:

See Also:

#descendant_by_path(path) ⇒ Accessible? #descendant_by_path(child_idx, grand_child_idx, *further_indices) ⇒ Accessible?

Returns its descendant found at the given path.

Overloads:

  • #descendant_by_path(path) ⇒ Accessible?

    Examples:

    descendant        # => #<ATSPI::Accessible:0xc1f18814 … @path=0/0/2/1 … >
    descendant.path   # => [0, 0, 2, 1]
    accessible.descendant_by_path(descendant.path) # => #<ATSPI::Accessible:0xc1f18814 … @path=0/0/2/1 … >
    

    Parameters:

    • path (Array)

      a path as returned by #path

  • #descendant_by_path(child_idx, grand_child_idx, *further_indices) ⇒ Accessible?

    Examples:

    accessible.descendant_by_path(0, 0, 2, 1) # => #<ATSPI::Accessible:0xc1f18814 … @path=0/0/2/1 … >
    

    Parameters:

Returns:

  • (Accessible, nil)

    its descendant found at the given path



177
178
179
180
181
182
# File 'lib/atspi/accessible.rb', line 177

def descendant_by_path(*path)
  path = path.flatten
  child = children[path.shift]
  found = child.nil? || path.empty?
  found ? child : child.descendant_by_path(path)
end

#descendantsDescendants

Returns its descendants. The collection will be empty if it does not implement the collection interface.

Returns:

See Also:



156
157
158
# File 'lib/atspi/accessible.rb', line 156

def descendants
  Descendants.new(@native)
end

#descriptionString

Returns its description.

Returns:

  • (String)

    its description

See Also:



87
# File 'lib/atspi/accessible.rb', line 87

delegate :description => :@native

#deselecttrue, false Originally defined in module Selectable

Deselects it

Returns:

  • (true, false)

    indicating success of the operation. false if its parent does not implement the selection interface.

See Also:

#desktopDesktop

Returns its desktop. That is the #parent of its #application.

Returns:



52
# File 'lib/atspi/accessible.rb', line 52

delegate :desktop => :application

#documentDocument?

Returns its document. It will be nil if it does not implement the document interface.

Returns:

See Also:



218
219
220
221
222
# File 'lib/atspi/accessible.rb', line 218

def document
  if @native.document_iface
    Document.new(@native)
  end
end

#extends?true, false Originally defined in module Extents

Checks if it is extending, that is it has a position and size. Accessibles implementing the component interface are extending.

Returns:

  • (true, false)

#extents(relative_to:) ⇒ ATSPI::Extents Originally defined in module Extents

Returns its extents. Will have a (0,0) position and a 0x0 size if it does not implement the component interface.

Examples:

accessible.extents(relative_to: :screen) # => #<ATSPI::Extents:0x10b62c814 @x=2192 @y=187 @width=655 @height=492>

Parameters:

  • relative_to (Symbol)

    coordinate system derived from libatspi’s AtspiCoordType enum by removing the prefix ATSPI_COORD_TYPE_ and making it lowercase

Returns:

See Also:

#grab_focustrue, false Originally defined in module Extents

Sets the input focus to it.

Returns:

  • (true, false)

    indicating success of the operation. false if it does not implement the component interface.

See Also:

Returns its hyperlink. It will be nil if it does not have a hyperlink.

Returns:

See Also:



244
245
246
247
248
# File 'lib/atspi/accessible.rb', line 244

def hyperlink
  if hyperlink = @native.hyperlink
    Hyperlink.new(hyperlink)
  end
end

#imageImage?

Returns its image. It will be nil if it does not implement the image interface.

Returns:

See Also:



255
256
257
258
259
# File 'lib/atspi/accessible.rb', line 255

def image
  if @native.image_iface
    Image.new(@native)
  end
end

#index_in_parentInteger Also known as: index

Returns the index in the collection of its #parent #children.

Returns:

See Also:



68
# File 'lib/atspi/accessible.rb', line 68

delegate :index_in_parent => :@native

#inspectString

Returns itself as an inspectable string.

Returns:

  • (String)

    itself as an inspectable string



284
285
286
287
288
# File 'lib/atspi/accessible.rb', line 284

def inspect
  "#<#{self.class.name}:0x#{'%x14' % __id__} @desktop=#{desktop.index} " <<
    "@application=#{application.name} @window=#{window.name} @path=#{path.join('/')} " <<
    "@name=#{name.inspect} @role=#{role.inspect} @extents=#{extents(relative_to: :screen).inspect}>"
end

#interfacesArray<String>

Returns the interfaces it implements.

Returns:

  • (Array<String>)

    the interfaces it implements

See Also:



134
135
136
# File 'lib/atspi/accessible.rb', line 134

def interfaces
  @native.interfaces.to_a
end

#layerSymbol Originally defined in module Extents

Returns its layer derived from libatspi’s AtspiComponentLayer enum by removing the prefix ATSPI_LAYER_ and making it lowercase. :invalid if it does not implement the component interface.

Returns:

See Also:

#localized_role_nameString

Returns its role as a localized string.

Returns:

  • (String)

    its role as a localized string

See Also:



103
# File 'lib/atspi/accessible.rb', line 103

delegate :localized_role_name => :@native

#mdi_z_orderInteger Originally defined in module Extents

Returns its mdi_z_order. -1 if it does not implement the component interface.

Returns:

See Also:

#nameString

Returns its name.

Returns:

  • (String)

    its name

See Also:



82
# File 'lib/atspi/accessible.rb', line 82

delegate :name => :@native

#opacityFloat Also known as: alpha Originally defined in module Extents

Returns its opacity between 0.0 (transparent) and 1.0 (opaque). 0.0 if it does not implement the component interface.

Returns:

  • (Float)

    its opacity between 0.0 (transparent) and 1.0 (opaque). 0.0 if it does not implement the component interface.

See Also:

#parentAccessible

Returns its parent.

Returns:

See Also:



143
144
145
# File 'lib/atspi/accessible.rb', line 143

def parent
  Accessible.new(@native.get_parent)
end

#pathArray<Integer>

Returns the list of #index_in_parent of all its ancestors until reaching its #window, exclusive.

Returns:



73
74
75
# File 'lib/atspi/accessible.rb', line 73

def path
  parent.path + [*index_in_parent]
end

#relationsHash<Symbol => Array<Accessible>>

Returns its relations to other accessibles. Keys name the relation type and values are relation targets.

Returns:

  • (Hash<Symbol => Array<Accessible>>)

    its relations to other accessibles. Keys name the relation type and values are relation targets.

See Also:



190
191
192
193
194
195
196
# File 'lib/atspi/accessible.rb', line 190

def relations
  @native.relation_set.to_a.inject({}) do |relations, relation|
    type = relation.relation_type
    targets = relation.n_targets.times.map{ |idx| Accessible.new(relation.target(idx)) }
    relations.merge!(type => targets)
  end
end

#roleSymbol

Returns its role derived from libatspi’s AtspiRole enum by removing the prefix ATSPI_ROLE_ and making it lowercase.

Returns:

  • (Symbol)

    its role derived from libatspi’s AtspiRole enum by removing the prefix ATSPI_ROLE_ and making it lowercase.

See Also:



93
# File 'lib/atspi/accessible.rb', line 93

delegate :role => :@native

#role_nameString

Returns its role as string.

Returns:

  • (String)

    its role as string

See Also:



98
# File 'lib/atspi/accessible.rb', line 98

delegate :role_name => :@native

#selecttrue, false Originally defined in module Selectable

Selects it

Returns:

  • (true, false)

    indicating success of the operation. false if its parent does not implement the selection interface.

See Also:

#selectable?true, false Originally defined in module Selectable

Checks if it can be selected. Accessibles which parent’s native implements the selection interface are selectable.

Returns:

  • (true, false)

#selected?true, false Originally defined in module Selectable

Checks if it currently is selected

Returns:

See Also:

#statesArray<Symbol>

Returns its states. They are symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making them lowercase.

Returns:

  • (Array<Symbol>)

    its states. They are symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making them lowercase.

See Also:



120
121
122
# File 'lib/atspi/accessible.rb', line 120

def states
  StateSet.new_from_native(@native.state_set).to_a
end

#tableTable?

Returns its table. It will be nil if it does not implement the table interface.

Returns:

See Also:



275
276
277
278
279
# File 'lib/atspi/accessible.rb', line 275

def table
  if @native.table_iface
    Table.new(@native)
  end
end

#textText?

Note:

The editable_text interface and hypertext interface are available through Text, too.

Returns its text. It will be nil if it does not implement the text interface.

Returns:

See Also:



234
235
236
237
238
# File 'lib/atspi/accessible.rb', line 234

def text
  if @native.text_iface
    Text.new(@native)
  end
end

#toolkit_nameString

Returns its toolkit’s name.

Returns:

  • (String)

    its toolkit’s name

See Also:



108
# File 'lib/atspi/accessible.rb', line 108

delegate :toolkit_name => :@native

#toolkit_versionString

Returns its toolkit’s version.

Returns:

  • (String)

    its toolkit’s version

See Also:



113
# File 'lib/atspi/accessible.rb', line 113

delegate :toolkit_version => :@native

#valueValue?

Returns its value. It will be nil if it does not implement the value interface.

Returns:

See Also:



265
266
267
268
269
# File 'lib/atspi/accessible.rb', line 265

def value
  if @native.value_iface
    Value.new(@native)
  end
end

#windowWindow

Returns its top level window. It is a child of its #application and has the #role :frame.

Returns:



63
# File 'lib/atspi/accessible.rb', line 63

delegate :window => :parent