Class: AX::ScrollArea

Inherits:
Element show all
Defined in:
lib/ax/scroll_area.rb

Overview

UI element for a view that can scroll? I'm not sure how else to describe it, the class name says it all.

Instance Method Summary collapse

Methods inherited from Element

#==, #actions, #ancestor, #ancestry, #application, #attribute, #attributes, #blank?, #bounds, #children, #description, #initialize, #inspect, #inspect_subtree, #invalid?, #method_missing, #methods, #parameterized_attribute, #parameterized_attributes, #perform, #pid, #respond_to?, #search, #set, #size_of, #to_h, #to_point, #to_s, #type, #writable?

Methods included from Accessibility::PrettyPrinter

#pp_checkbox, #pp_children, #pp_enabled, #pp_focused, #pp_identifier, #pp_position

Constructor Details

This class inherits a constructor from AX::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AX::Element

Instance Method Details

#scroll_to(element)

This method returns an undefined value.

Scroll through the receiver until the given element is visible.

If you need to scroll an unknown amount of units through a scroll area, or something in a scroll area (i.e. a table), you can just pass the element that you are trying to get to and this method will scroll to it for you.

Examples:


scroll_area.scroll_to table.rows.last

Parameters:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ax/scroll_area.rb', line 23

def scroll_to element
  return if NSContainsRect(self.bounds, element.bounds)
  Mouse.move_to self.to_point

  # calculate direction and velocity for scrolling
  direction = element.position.y > self.position.y ? -5 : 5

  Mouse.scroll direction until NSContainsRect(self.bounds, element.bounds)

  spin 0.1
end