Module: Bewildr::ControlPatterns::SelectionPattern

Defined in:
lib/bewildr/control_patterns/selection_pattern.rb

Instance Method Summary collapse

Instance Method Details

#get_selectionObject

Returns the elements that are selected



7
8
9
10
11
12
13
14
15
# File 'lib/bewildr/control_patterns/selection_pattern.rb', line 7

def get_selection
  my_selected_items = @automation_element.get_current_pattern(System::Windows::Automation::SelectionPattern.pattern).current.get_selection

  c_array_list = System::Collections::ArrayList.new(my_selected_items)
  item_array = c_array_list.to_array.to_a

  return [] if item_array.size == 0
  item_array.to_a.collect {|item| Bewildr::Element.new(item)}
end

#multi_selectable?Boolean Also known as: can_select_multiple?

Returns true if more than one selection is possible, false if it’s not

Returns:

  • (Boolean)


18
19
20
# File 'lib/bewildr/control_patterns/selection_pattern.rb', line 18

def multi_selectable?
  @automation_element.get_current_pattern(System::Windows::Automation::SelectionPattern.pattern).current.can_select_multiple
end

#selectedObject

Returns the (first - if relevant) selected item



24
25
26
# File 'lib/bewildr/control_patterns/selection_pattern.rb', line 24

def selected
  multi_selectable? ? get_selection : get_selection.first
end