docs » cp.ui.Button


Button Module.

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

API Documentation

Functions

matches

Signature cp.ui.Button.matches(element) -> boolean
Type Function
Description Checks if the element is a Button, returning true if so.
Parameters
  • * element - The `hs._asm.axuielement` to check.
Returns
  • * `true` if the `element` is a `Button`, or `false` if not.

Constructors

new

Signature cp.ui.Button.new(parent, finderFn) -> cp.ui.Button
Type Constructor
Description Creates a new Button instance.
Parameters
  • * parent - The parent object. Should have a `UI` and `isShowing` field.
  • * finderFn - A function which will return the `hs._asm.axuielement` the button belongs to, or `nil` if not available.
Returns
  • The new `Button` instance.

Fields

frame

Signature cp.ui.Button.frame <cp.prop: table; read-only>
Type Field
Description Returns the table containing the x, y, w, and h values for the button frame, or nil if not available.

isShowing

Signature cp.ui.Button.isShowing <cp.prop: boolean; read-only>
Type Field
Description If true, the Button is showing on screen.

title

Signature cp.ui.Button.title <cp.prop: string; read-only>
Type Field
Description The button title, if available.

UI

Signature cp.ui.Button.UI <cp.prop: hs._asm.axuielement; read-only>
Type Field
Description Retrieves the axuielement for the Button, or nil if not available..

Methods

isEnabled

Signature cp.ui.Button:isEnabled() -> boolean
Type Method
Description Returns true if the button is visible and enabled.
Parameters
  • * None
Returns
  • * `true` if the button is visible and enabled.

press

Signature cp.ui.Button:press() -> self
Type Method
Description Performs a button press action, if the button is available.
Parameters
  • * None
Returns
  • * The `Button` instance.

snapshot

Signature `cp.ui.Button:snapshot([path]) -> hs.image nil` </span>
Type Method
Description Takes a snapshot of the button in its current state as a PNG and returns it.
Parameters
  • * path - (optional) The path to save the file. Should include the extension (should be `.png`).

results matching ""

    No results matching ""