#cp.ui.RadioButton

Radio Button Module.

This represents an hs.axuielement with a AXRadioButton role. It allows checking and modifying the checked status like so:

myButton:checked() == true -- happens to be checked already myButton:checked(false) == false -- update to unchecked. myButton.checked:toggle() == true -- toggled back to being checked.

You can also call instances of RadioButton as a function, which will return the checked status:

myButton() == true -- still true myButton(false) == false -- now false

#API Overview

Functions - API calls offered directly by the extension

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

Signaturecp.ui.RadioButton.matches(element) -> boolean
TypeFunction
DescriptionChecks if the provided hs.axuielement is a RadioButton.
Parameters
  • element - The axuielement to check.
Returns
  • true if it's a match, or false if not.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 32

#Fields

Signaturecp.ui.RadioButton.checked <cp.prop: boolean>
TypeField
DescriptionIndicates if the checkbox is currently checked. May be set by calling as a function with true or false to the function.
NotesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 59

#Methods

Signaturecp.ui.RadioButton:doCheck() -> cp.rx.go.Statement
TypeMethod
DescriptionReturns a Statement that will check the button value when executed, if available at the time. If not an error is sent.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 110

Signaturecp.ui.RadioButton:doLayout(layout) -> cp.rx.go.Statement
TypeMethod
DescriptionReturns 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
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 202

Signaturecp.ui.RadioButton:doPress() -> cp.rx.go.Statement
TypeMethod
DescriptionReturns a Statement that will press the button when executed, if available at the time. If not an error is sent.
Parameters
  • None
Returns
  • The Statement which will press the button when executed.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 157

Signaturecp.ui.RadioButton:doToggle() -> cp.rx.go.Statement
TypeMethod
DescriptionReturns a Statement that will toggle the button value when executed, if available at the time. If not an error is sent.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 91

Signaturecp.ui.RadioButton:doUncheck() -> cp.rx.go.Statement
TypeMethod
DescriptionReturns a Statement that will uncheck the button value when executed, if available at the time. If not an error is sent.
Parameters
  • None
Returns
  • The Statement which will toggle the button when executed.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 125

Signaturecp.ui.RadioButton:loadLayout(layout) -> nil
TypeMethod
DescriptionProcesses the layout table to restore this to match the provided layout.
Parameters
  • layout - the table of state values to restore to.
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 186

Signaturecp.ui.RadioButton:press() -> self
TypeMethod
DescriptionAttempts to press the button. May fail if the UI is not available.
Parameters
  • None
Returns
  • The RadioButton instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 140

Signaturecp.ui.RadioButton(axuielement, function) -> RadioButton
TypeMethod
DescriptionCreates a new RadioButton.
Parameters
  • parent - The parent object.
  • finderFn - A function which will return the hs.axuielement when available.
Returns
  • The new RadioButton.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 45

Signaturecp.ui.RadioButton:saveLayout() -> table
TypeMethod
DescriptionReturns a table with the button's current state. This can be passed to [#loadLayout] later to restore the original state.
Parameters
  • None
Returns
  • The table of the layout state.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 171

Signaturecp.ui.RadioButton:toggle() -> self
TypeMethod
DescriptionToggles the checked status of the button.
Parameters
  • None
Returns
  • The RadioButton instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/RadioButton.lua line 77