Internationalisation
Bundled Plugins API
MenuButton
Menu Button Module.

API Overview

API Documentation

Functions

matches

Signature
cp.ui.MenuButton.matches(element) -> boolean
Type
Function
Description
Checks to see if an element matches what we think it should be.
Parameters
  • element - An axuielementObject to check.
Returns
  • true if matches otherwise false

Constructors

Signature
cp.ui.MenuButton(parent, uiFinder) -> MenuButton
Type
Constructor
Description
Creates a new MenuButton.
Parameters
  • parent - The parent object. Should have an isShowing property.
  • uiFinder - A cp.prop or function which will return a hs._asm.axuielement, or nil if it's not available.

Fields

Signature
cp.ui.MenuButton.menuUI <cp.prop: hs._asm.axuielement; read-only; live?>
Type
Field
Description
Returns the AXMenu for the MenuButton if it is currently visible.

title

Signature
cp.ui.MenuButton.title <cp.prop: string; read-only>
Type
Field
Description
Returns the title for the MenuButton.

value

Signature
cp.ui.MenuButton.value <cp.prop: anything>
Type
Field
Description
Returns or sets the current MenuButton value.

Methods

doPress

Signature
cp.ui.MenuButton:doPress() -> cp.rx.go.Statement
Type
Method
Description
A Statement that presses the MenuButton.
Parameters
  • None
Returns
Signature
cp.ui.MenuButton:doSelectItem(index) -> cp.rx.go.Statement
Type
Method
Description
A Statement that will select an item on the MenuButton by index.
Parameters
  • index - The index number of the item to match.
Returns
  • the Statement.
Signature
cp.ui.MenuButton:doSelectItemMatching(pattern[, altPattern]) -> cp.rx.go.Statement
Type
Method
Description
A Statement that will select an item on the MenuButton by pattern.
Parameters
  • pattern - The pattern to match.
  • [altPattern] - An optional alternate pattern to match if the first pattern fails.
Returns
  • the Statement.
Signature
cp.ui.MenuButton:doSelectValue(value) -> cp.rx.go.Statement
Type
Method
Description
A Statement that will select an item on the MenuButton by value.
Parameters
  • value - The value of the item to match.
Returns
  • the Statement.
Signature
cp.ui.MenuButton:doShowMenu() -> cp.rx.go.Statement
Type
Method
Description
A Statement that presses the MenuButton if the menu is not showing.
Parameters
  • None
Returns

getTitle

| Signature | cp.ui.MenuButton:getTitle() -> string | nil | | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Gets the MenuButton title. | | Parameters |
  • None
| | Returns |
  • The MenuButton title as string, or nil if the title cannot be determined.
|

getValue

| Signature | cp.ui.MenuButton:getValue() -> string | nil | | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Gets the MenuButton value. | | Parameters |
  • None
| | Returns |
  • The MenuButton value as string, or nil if the value cannot be determined.
|
Signature
cp.ui.MenuButton:loadLayout(layout) -> none
Type
Method
Description
Loads a MenuButton layout.
Parameters
  • layout - A table containing the MenuButton layout settings - created using saveLayout.
Returns
  • None

press

Signature
cp.ui.MenuButton:press() -> self
Type
Method
Description
Presses the MenuButton.
Parameters
  • None
Returns
  • self
Signature
cp.ui.MenuButton:saveLayout() -> table
Type
Method
Description
Saves the current MenuButton layout to a table.
Parameters
  • None
Returns
  • A table containing the current MenuButton Layout.
Signature
cp.ui.MenuButton:selectItem(index) -> boolean
Type
Method
Description
Select an item on the MenuButton by index.
Parameters
  • index - The index of the item you want to select.
Returns
  • true if successfully selected, otherwise false.
Signature
cp.ui.MenuButton:selectItemMatching(pattern) -> boolean
Type
Method
Description
Select an item on the MenuButton by pattern.
Parameters
  • pattern - A pattern used to select the MenuButton item.
Returns
  • true if successfully selected, otherwise false.

setValue

Signature
cp.ui.MenuButton:setValue(value) -> self
Type
Method
Description
Sets the MenuButton value.
Parameters
  • value - The value you want to set the MenuButton to.
Returns
  • self

show

Signature
cp.ui.MenuButton:show() -> self
Type
Method
Description
Show's the MenuButton.
Parameters
  • None
Returns
  • self
Last modified 1mo ago