Class: ATSPI::Accessible
- Inherits:
-
Object
- Object
- ATSPI::Accessible
- 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
Defined Under Namespace
Modules: Extents, Selectable Classes: Action, Children, Descendants, Document, Hyperlink, Image, Table, Text, Value
Identification collapse
-
#application ⇒ Application
Its application.
-
#desktop ⇒ Desktop
Its desktop.
- #index_in_parent ⇒ Integer (also: #index)
-
#path ⇒ Array<Integer>
The list of #index_in_parent of all its ancestors until reaching its #window, exclusive.
-
#window ⇒ Window
Its top level window.
Attributes & States collapse
-
#attributes ⇒ Hash<String => String>
Its attributes.
-
#contains?(x, y, relative_to:) ⇒ true, false
included
from Extents
Checks if the given point lies within its bounds.
-
#description ⇒ String
Its description.
-
#extends? ⇒ true, false
included
from Extents
Checks if it is extending, that is it has a position and size.
-
#extents(relative_to:) ⇒ ATSPI::Extents
included
from Extents
Its extents.
-
#interfaces ⇒ Array<String>
The interfaces it implements.
-
#layer ⇒ Symbol
included
from Extents
Its layer derived from libatspi’s AtspiComponentLayer enum by removing the prefix
ATSPI_LAYER_and making it lowercase. -
#localized_role_name ⇒ String
Its role as a localized string.
-
#mdi_z_order ⇒ Integer
included
from Extents
Its mdi_z_order.
-
#name ⇒ String
Its name.
-
#opacity ⇒ Float
(also: #alpha)
included
from Extents
Its opacity between
0.0(transparent) and1.0(opaque). -
#role ⇒ Symbol
Its role derived from libatspi’s AtspiRole enum by removing the prefix
ATSPI_ROLE_and making it lowercase. -
#role_name ⇒ String
Its role as string.
-
#selectable? ⇒ true, false
included
from Selectable
Checks if it can be selected.
-
#selected? ⇒ true, false
included
from Selectable
Checks if it currently is selected.
-
#states ⇒ Array<Symbol>
Its states.
-
#toolkit_name ⇒ String
Its toolkit’s name.
-
#toolkit_version ⇒ String
Its toolkit’s version.
Tree & Traversal collapse
-
#children ⇒ Children
Its children.
-
#descendant_at(x, y, relative_to:) ⇒ Accessible?
included
from Extents
The descendant at the given coordinates.
-
#descendant_by_path(*path) ⇒ Accessible?
Its descendant found at the given path.
-
#descendants ⇒ Descendants
Its descendants.
-
#parent ⇒ Accessible
Its parent.
-
#relations ⇒ Hash<Symbol => Array<Accessible>>
Its relations to other accessibles.
Actions collapse
-
#actions ⇒ Array<Action>
The actions it supports.
-
#deselect ⇒ true, false
included
from Selectable
Deselects it.
-
#grab_focus ⇒ true, false
included
from Extents
Sets the input focus to it.
-
#select ⇒ true, false
included
from Selectable
Selects it.
Representative for collapse
-
#document ⇒ Document?
Its document.
-
#hyperlink ⇒ Hyperlink?
(also: #link)
Its hyperlink.
-
#image ⇒ Image?
Its image.
-
#table ⇒ Table?
Its table.
-
#text ⇒ Text?
Its text.
-
#value ⇒ Value?
Its value.
Representations collapse
-
#inspect ⇒ String
Itself as an inspectable string.
Instance Method Details
#actions ⇒ Array<Action>
Returns the actions it supports. The array will be empty if it does not implement the action interface.
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 |
#application ⇒ Application
Returns its application.
57 58 59 |
# File 'lib/atspi/accessible.rb', line 57 def application Application.new(@native.application) end |
#attributes ⇒ Hash<String => String>
Returns its attributes.
127 128 129 |
# File 'lib/atspi/accessible.rb', line 127 def attributes @native.attributes.to_h end |
#children ⇒ Children
Returns its children.
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
#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.
#descendant_by_path(path) ⇒ Accessible? #descendant_by_path(child_idx, grand_child_idx, *further_indices) ⇒ Accessible?
Returns 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 |
#descendants ⇒ Descendants
Returns its descendants. The collection will be empty if it does not implement the collection interface.
156 157 158 |
# File 'lib/atspi/accessible.rb', line 156 def descendants Descendants.new(@native) end |
#description ⇒ String
Returns its description.
87 |
# File 'lib/atspi/accessible.rb', line 87 delegate :description => :@native |
#deselect ⇒ true, false Originally defined in module Selectable
Deselects it
#desktop ⇒ Desktop
Returns its desktop. That is the #parent of its #application.
52 |
# File 'lib/atspi/accessible.rb', line 52 delegate :desktop => :application |
#document ⇒ Document?
Returns its document. It will be nil if it does not implement the document interface.
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.
#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.
#grab_focus ⇒ true, false Originally defined in module Extents
Sets the input focus to it.
#hyperlink ⇒ Hyperlink? Also known as: link
Returns its hyperlink. It will be nil if it does not have a hyperlink.
244 245 246 247 248 |
# File 'lib/atspi/accessible.rb', line 244 def hyperlink if hyperlink = @native.hyperlink Hyperlink.new(hyperlink) end end |
#image ⇒ Image?
Returns its image. It will be nil if it does not implement the image interface.
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_parent ⇒ Integer Also known as: index
68 |
# File 'lib/atspi/accessible.rb', line 68 delegate :index_in_parent => :@native |
#inspect ⇒ String
Returns 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 |
#interfaces ⇒ Array<String>
Returns the interfaces it implements.
134 135 136 |
# File 'lib/atspi/accessible.rb', line 134 def interfaces @native.interfaces.to_a end |
#layer ⇒ Symbol 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.
#localized_role_name ⇒ String
Returns its role as a localized string.
103 |
# File 'lib/atspi/accessible.rb', line 103 delegate :localized_role_name => :@native |
#mdi_z_order ⇒ Integer Originally defined in module Extents
Returns its mdi_z_order. -1 if it does not implement the component interface.
#name ⇒ String
Returns its name.
82 |
# File 'lib/atspi/accessible.rb', line 82 delegate :name => :@native |
#opacity ⇒ Float 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.
#parent ⇒ Accessible
Returns its parent.
143 144 145 |
# File 'lib/atspi/accessible.rb', line 143 def parent Accessible.new(@native.get_parent) end |
#path ⇒ Array<Integer>
Returns the list of #index_in_parent of all its ancestors until reaching its #window, exclusive.
73 74 75 |
# File 'lib/atspi/accessible.rb', line 73 def path parent.path + [*index_in_parent] end |
#relations ⇒ Hash<Symbol => Array<Accessible>>
Returns its relations to other accessibles. Keys name the relation type and values are relation targets.
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 |
#role ⇒ Symbol
Returns its role derived from libatspi’s AtspiRole enum by removing the prefix ATSPI_ROLE_ and making it lowercase.
93 |
# File 'lib/atspi/accessible.rb', line 93 delegate :role => :@native |
#role_name ⇒ String
Returns its role as string.
98 |
# File 'lib/atspi/accessible.rb', line 98 delegate :role_name => :@native |
#select ⇒ true, false Originally defined in module Selectable
Selects it
#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.
#selected? ⇒ true, false Originally defined in module Selectable
Checks if it currently is selected
#states ⇒ Array<Symbol>
Returns its states. They are symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making them lowercase.
120 121 122 |
# File 'lib/atspi/accessible.rb', line 120 def states StateSet.new_from_native(@native.state_set).to_a end |
#table ⇒ Table?
Returns its table. It will be nil if it does not implement the table interface.
275 276 277 278 279 |
# File 'lib/atspi/accessible.rb', line 275 def table if @native.table_iface Table.new(@native) end end |
#text ⇒ Text?
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.
234 235 236 237 238 |
# File 'lib/atspi/accessible.rb', line 234 def text if @native.text_iface Text.new(@native) end end |
#toolkit_name ⇒ String
Returns its toolkit’s name.
108 |
# File 'lib/atspi/accessible.rb', line 108 delegate :toolkit_name => :@native |
#toolkit_version ⇒ String
Returns its toolkit’s version.
113 |
# File 'lib/atspi/accessible.rb', line 113 delegate :toolkit_version => :@native |
#value ⇒ Value?
Returns its value. It will be nil if it does not implement the value interface.
265 266 267 268 269 |
# File 'lib/atspi/accessible.rb', line 265 def value if @native.value_iface Value.new(@native) end end |
#window ⇒ Window
Returns its top level window. It is a child of its #application and has the #role :frame.
63 |
# File 'lib/atspi/accessible.rb', line 63 delegate :window => :parent |