Method: Accessibility::Core#attribute
- Defined in:
- lib/accessibility/core.rb
#attribute(name) ⇒ Object
Fetch the value for an attribute. CoreFoundation wrapped objects will be unwrapped for you, if you expect to get a CFRange you will be given a Range instead.
As a convention, if the backing element is no longer alive, or
the attribute does not exist, or a system failure occurs then
you will receive nil
for any attribute except for
KAXChildrenAttribute
. KAXChildrenAttribute
will always return
an array.
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/accessibility/core.rb', line 102 def attribute name ptr = Pointer.new :id case code = AXUIElementCopyAttributeValue(self, name, ptr) when 0 ptr.value.to_ruby when KAXErrorNoValue, KAXErrorAttributeUnsupported, KAXErrorFailure, KAXErrorInvalidUIElement, KAXErrorIllegalArgument then name == KAXChildrenAttribute ? [] : nil else handle_error code, name end end |