#cp.ui.Element
A support class for hs.axuielement
management.
See:
#API Overview
Functions - API calls offered directly by the extension
Constructors - API calls which return an object, typically one that offers API methods
Fields - Variables which can only be accessed from an object returned by a constructor
Methods - API calls which can only be made on an object returned by a constructor
- app
- attributeValue
- defineBuilder
- doFocus
- doHighlight
- doLayout
- doPerformAction
- doSetAttributeValue
- doShow
- focus
- highlight
- loadLayout
- parent
- performAction
- saveLayout
- setAttributeValue
- show
- snapshot
- valueIs
#API Documentation
#Functions
Signature | cp.ui.Element:isTypeOf(thing) -> boolean |
Type | Function |
Description | Checks if the thing is an Element . If called on subclasses, it will check if the thing is an instance of the subclass. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 86 |
Signature | cp.ui.Element.matches(element) -> boolean |
Type | Function |
Description | Matches to any valid hs.axuielement . Sub-types should provide their own matches method. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 103 |
#Constructors
Signature | cp.ui.Element(parent, uiFinder) -> cp.ui.Element |
Type | Constructor |
Description | Creates a new Element with the specified parent and uiFinder . The uiFinder may be either a function that returns an axuielement , or a cp.prop. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 121 |
#Fields
Signature | cp.ui.Element.frame <cp.prop: table; read-only; live?> |
Type | Field |
Description | Returns the table containing the x , y , w , and h values for the Element frame, or nil if not available. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 386 |
Signature | cp.ui.Element.identifier <cp.prop: string; read-only> |
Type | Field |
Description | Returns the AX identifier for the element. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 372 |
Signature | cp.ui.Element.isEnabled <cp.prop: boolean; read-only> |
Type | Field |
Description | Returns true if the Element is visible and enabled. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 379 |
Signature | cp.ui.Element.isFocused <cp.prop: boolean; read-only?; live?> |
Type | Field |
Description | Returns true if the AXFocused attribute is true . Not always a reliable way to determine focus however. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 393 |
Signature | cp.ui.Element.isShowing <cp.prop: boolean; read-only; live?> |
Type | Field |
Description | If true , the Element is showing on screen. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 194 |
Signature | cp.ui.Element.position <cp.prop: table; read-only; live?> |
Type | Field |
Description | Returns the table containing the x and y values for the Element frame, or nil if not available. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 400 |
Signature | cp.ui.Element.role <cp.prop: string; read-only> |
Type | Field |
Description | Returns the AX role name for the element. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 358 |
Signature | cp.ui.Element.size <cp.prop: table; read-only; live?> |
Type | Field |
Description | Returns the table containing the w and h values for the Element frame, or nil if not available. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 408 |
Signature | cp.ui.Element.subrole <cp.prop: string; read-only> |
Type | Field |
Description | Returns the AX subrole name for the element. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 365 |
Signature | cp.ui.Element.textValue <cp.prop: string; read-only; live?> |
Type | Field |
Description | The 'AXValue' of the element, if it is a string . |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 164 |
Signature | cp.ui.Element.title <cp.prop: string; read-only, live?> |
Type | Field |
Description | The 'AXTitle' of the element. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 187 |
Signature | cp.ui.Element.value <cp.prop: anything; live?> |
Type | Field |
Description | The 'AXValue' of the element. |
Notes | None |
Source | src/extensions/cp/ui/Element.lua line 157 |
#Methods
Signature | cp.ui.Element:app() -> App |
Type | Method |
Description | Returns the app instance. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 429 |
Signature | cp.ui.Element:attributeValue(id) -> anything, true | nil, false |
Type | Method |
Description | Attempts to retrieve the specified AX attribute value, if the UI is available. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 265 |
Signature | cp.ui.Element:defineBuilder(...) -> cp.ui.Element |
Type | Method |
Description | Defines a new Builder class on this Element with the specified additional argument names. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 33 |
Signature | cp.ui.Element:doFocus() -> cp.rx.go.Statement |
Type | Method |
Description | A Statement that attempts to set the focus on the element. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 251 |
Signature | cp.ui.Element:doHighlight([color], [duration]) -> cp.rx.go.Statement |
Type | Method |
Description | Returns a Statement which will attempt to highlight the Element with the specified color and duration . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 462 |
Signature | cp.ui.Element:doLayout(layout) -> cp.rx.go.Statement |
Type | Method |
Description | Returns a Statement which will attempt to load the layout based on the parameters provided by the layout table. This table should generally be generated via the [#saveLayout] method. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 574 |
Signature | cp.ui.Element:doPerformAction(id) -> cp.rx.go.Statement |
Type | Method |
Description | Returns a Statement which will attempt to perform the action with the specified id (eg. "AXCancel") |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 339 |
Signature | cp.ui.Element:doSetAttributeValue(id, value) -> cp.rx.go.Statement |
Type | Method |
Description | Returns a Statement which will attempt to update the specified AX attribute to the new value . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 319 |
Signature | cp.ui.Element:doShow() -> cp.rx.go.Statement |
Type | Method |
Description | Returns a Statement that will ensure the Element is showing. By default, will ask the parent to show, if the parent is available. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 206 |
Signature | cp.ui.Element:focus() -> self, boolean |
Type | Method |
Description | Attempt to set the focus on the element. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 238 |
Signature | cp.ui.Element:highlight([color], [duration]) -> cp.ui.Element |
Type | Method |
Description | Highlights the Element with the specified color and duration . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 507 |
Signature | cp.ui.Element:loadLayout(layout) -> nil |
Type | Method |
Description | When called, the Element (or subclass) will attempt to load the layout based on the parameters provided by the layout table. This table should generally be generated via the [#saveLayout] method. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 547 |
Signature | cp.ui.Element:parent() -> parent |
Type | Method |
Description | Returns the parent object. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 416 |
Signature | cp.ui.Element:performAction(id) -> boolean |
Type | Method |
Description | Attempts to perform the specified AX action, if the UI is available. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 301 |
Signature | cp.ui.Element:saveLayout() -> table |
Type | Method |
Description | Returns a table containing the current configuration details for this Element (or subclass). |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 523 |
Signature | cp.ui.Element:setAttributeValue(id, value) -> self, boolean |
Type | Method |
Description | If the UI is available, set the named AX attribute to the value . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 282 |
Signature | cp.ui.Element:show() -> self |
Type | Method |
Description | Shows the Element. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 221 |
Signature | cp.ui.Element:snapshot([path]) -> hs.image | nil |
Type | Method |
Description | Takes a snapshot of the button in its current state as a PNG and returns it. If the path is provided, the image will be saved at the specified location. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 443 |
Signature | cp.ui.Element.valueIs(value) -> boolean |
Type | Method |
Description | Checks if the current value of this element is the provided value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/ui/Element.lua line 174 |