Internationalisation
Bundled Plugins API
RadioButton
Radio Button Module.
This represents an hs._asm.axuielement with a AXRadioButton role. It allows checking and modifying the checked status like so:
1
myButton:checked() == true -- happens to be checked already
2
myButton:checked(false) == false -- update to unchecked.
3
myButton.checked:toggle() == true -- toggled back to being checked.
Copied!
You can also call instances of RadioButton as a function, which will return the checked status:
1
myButton() == true -- still true
2
myButton(false) == false -- now false
Copied!

API Overview

API Documentation

Functions

matches

Signature
cp.ui.RadioButton.matches(element) -> boolean
Type
Function
Description
Checks if the provided hs._asm.axuielement is a RadioButton.
Parameters
  • element - The axuielement to check.
Returns
  • true if it's a match, or false if not.

Fields

checked

Signature
cp.ui.RadioButton.checked <cp.prop: boolean>
Type
Field
Description
Indicates if the checkbox is currently checked.

Methods

doCheck

Signature
cp.ui.RadioButton:doCheck() -> cp.rx.go.Statement
Type
Method
Description
Returns a Statement that will check the button value when executed, if available at the time.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.

doLayout

Signature
cp.ui.RadioButton:doLayout(layout) -> cp.rx.go.Statement
Type
Method
Description
Returns a Statement that will apply the layout provided, if possible.
Parameters
  • layout - the table containing the layout configuration. Usually created via the [#saveLayout] method.
Returns

doPress

Signature
cp.ui.RadioButton:doPress() -> cp.rx.go.Statement
Type
Method
Description
Returns a Statement that will press the button when executed, if available at the time.
Parameters
  • None
Returns
  • The Statement which will press the button when executed.

doToggle

Signature
cp.ui.RadioButton:doToggle() -> cp.rx.go.Statement
Type
Method
Description
Returns a Statement that will toggle the button value when executed, if available at the time.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.

doUncheck

Signature
cp.ui.RadioButton:doUncheck() -> cp.rx.go.Statement
Type
Method
Description
Returns a Statement that will uncheck the button value when executed, if available at the time.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.
Signature
cp.ui.RadioButton:loadLayout(layout) -> nil
Type
Method
Description
Processes the layout table to restore this to match the provided layout.
Parameters
  • layout - the table of state values to restore to.

press

Signature
cp.ui.RadioButton:press() -> self
Type
Method
Description
Attempts to press the button. May fail if the UI is not available.
Parameters
  • None
Returns
The RadioButton instance.
Signature
cp.ui.RadioButton(axuielement, function) -> RadioButton
Type
Method
Description
Creates a new RadioButton.
Parameters
  • parent - The parent object.
  • finderFn - A function which will return the hs._asm.axuielement when available.
Returns
  • The new RadioButton.
Signature
cp.ui.RadioButton:saveLayout() -> table
Type
Method
Description
Returns a table with the button's current state. This can be passed to [#loadLayout]
Returns
  • The table of the layout state.

toggle

Signature
cp.ui.RadioButton:toggle() -> self
Type
Method
Description
Toggles the checked status of the button.
Parameters
  • None
Returns
  • The RadioButton instance.
Last modified 1mo ago