Class: ATSPI::Accessible::Children

Inherits:
Object
  • Object
show all
Includes:
SelectableCollection
Defined in:
lib/atspi/accessible/children.rb

Overview

Wraps the children part of libatspi’s AtspiAccessible and parts of AtspiSelection.

Instance are enumerables supporting item access and can be treated more or less like an array.

Direct Known Subclasses

Table::Cells

Defined Under Namespace

Classes: Selected

Enumerable interface collapse

Selection collapse

Filter collapse

Options collapse

Representation collapse

Instance Method Details

#[](idx) ⇒ Object Originally defined in module Collection

alias for #at

#at(idx) ⇒ Accessible

Returns its child at index idx.



21
22
23
24
25
# File 'lib/atspi/accessible/children.rb', line 21

def at(idx)
  super do |mapped_idx|
    Accessible.new(@native.child_at_index(mapped_idx))
  end
end

#countInteger

Returns its number of children.



30
31
32
# File 'lib/atspi/accessible/children.rb', line 30

def count
  @native.child_count
end

#deselect_alltrue, false

Tries to deselect all children



70
71
72
# File 'lib/atspi/accessible/children.rb', line 70

def deselect_all
  selectable? and @native.clear_selection
end

#eachObject Originally defined in module Collection

prerequisite for Enumerable

#inspectString Originally defined in module SelectableCollection

#last(n = 1) ⇒ Object+ Originally defined in module Collection

#lengthObject Originally defined in module Collection

alias for #count

#limit_to(limit) ⇒ Descendants

Returns the children collection as limited descendants collection.



100
101
102
# File 'lib/atspi/accessible/children.rb', line 100

def limit_to(limit)
  Accessible::Descendants.new(@native).recursive(false).limit_to(limit)
end

#recursive(recursive = true) ⇒ Descendants, self

Returns self if recursive is set to false. A collection of all descendants if recursive is set to true.



108
109
110
111
112
113
114
# File 'lib/atspi/accessible/children.rb', line 108

def recursive(recursive = true)
  if recursive
    Accessible::Descendants.new(@native)
  else
    self
  end
end

#select_alltrue, false

Tries to select all children



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

def select_all
  selectable? and @native.select_all
end

#selectable?true, false

Checks if the accessible the children belong to implements the selection interface.



42
43
44
# File 'lib/atspi/accessible/children.rb', line 42

def selectable?
  not @native.selection_iface.nil?
end

#selectedSelected, []



48
49
50
51
52
53
54
# File 'lib/atspi/accessible/children.rb', line 48

def selected
  if selectable?
    Selected.new(@native)
  else
    []
  end
end

#sizeObject Originally defined in module Collection

alias for #count

#sort_by(order) ⇒ Descendants

Returns the children collection as sorted descendants collection.

Examples:

descendants.sort_by(:flow) # => #<ATSPI::Accessible::Descendants:0x101c51014 … >

See Also:



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

def sort_by(order)
  Accessible::Descendants.new(@native).recursive(false).sort_by(order)
end

#where(state: ) ⇒ Descendants #where(attributes: ) ⇒ Descendants #where(role: ) ⇒ Descendants #where(interface: ) ⇒ Descendants #where(name: ) ⇒ Descendants #where(filters) ⇒ Descendants

Note:

Filtering sometimes felt rocky on libatspi’s side during testing. See the notes in the following sections for details.

Returns the children collection as filtered descendants collection.

Overloads:

  • #where(state: ) ⇒ Descendants

    Filters by state(s)

    Examples:

    # Selects accessibles in state :selected
    where(state: :selected)
    
    # Selects accessibles in both states :selectable *and* :selected
    where(state: [:selectable, :selected])
    
    # Selects accessibles in either state :selectable *or* :selected (or both)
    where(state: [:selectable, :selected, mode: :any])
    
  • #where(attributes: ) ⇒ Descendants
    Note:

    Filtering attributes in mode :all effectively disables the filter and returns all descendants. It does not narrow down the result set as one would expect.

    Filters by attribute(s)

    Examples:

    # Selects accessibles with value "button" for attribute "tag"
    where(attributes: { "tag" => "button" })
    
    # Selects accessibles with value "button" *or* "input" for attribute "tag"
    where(attributes: { "tag" => ["button", "input"] })
    
    # Selects accessibles with value "button" for attribute "tag" *or* value "block" for attribute "display"
    where(attributes: { "tag" => "button", "display" => "block" })
    
  • #where(role: ) ⇒ Descendants
    Note:

    Setting the mode to a value different from :any for role filters effectively disables the filter and returns all descendants. Since an accessible has only exactly one role, one would expect that it does return an empty set, but it does not.

    Filters by role

    Examples:

    # Selects accessibles with role :frame
    where(role: :frame)
    
    # Selects accessibles with role :page_tab_list *or* :page_tab
    where(role: [:page_tab_list, :page_tab])
    
  • #where(interface: ) ⇒ Descendants
    Note:

    Filtering by multiple interfaces and including :Accessible or :Collection in mode :all does not work. Instead it always returns an empty set.

    Note:

    Filtering interfaces in mode :none effectively disables the filter and returns the entire set of descendants. Since an accessible always has at least the accessible interfaces it implements one would expect that it does return an empty set, but it does not.

    Filters by interface(s)

    Examples:

    # Selects accessibles implementing Action
    where(interface: :Action)
    
    # Selects accessibles implementing Action+ *and* Selection
    where(interface: [:Action, :Selection])
    
    # Selects accessibles implementing Action *or* +Selection or both
    where(interface: [:Action, :Selection, mode: :any])
    
  • #where(name: ) ⇒ Descendants

    Filters by name

    Examples:

    # Selects accessibles with name exactly "Accessibles Name"
    where(name: "Accessible Name")
    
    # Selects accessibles with a name matching /a.{11}y/
    where(name: /a.{11}y/)
    
  • #where(filters) ⇒ Descendants

    Combines all or a subset of filters in a single call.

    Examples:

    where(name: /a.{11}y/, state: [:selectable, :selected], role: :page_tab)
    

    Options Hash (filters):

    • :states (Symbol, Array)
    • :role (Symbol, Array)
    • :name (String, RegExp)
    • :attributes (Hash)
    • :interface (Symbol, Array)

See Also:



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

def where(*args)
  Accessible::Descendants.new(@native).recursive(false).where(*args)
end