# cp.ui.MenuButton

Menu Button Module.


# API Overview

Functions - API calls offered directly by the extension

  • matches

Constructors - API calls which return an object, typically one that offers API methods

  • MenuButton

Fields - Variables which can only be accessed from an object returned by a constructor

  • menuUI
  • title
  • value

Methods - API calls which can only be made on an object returned by a constructor

  • doPress
  • doSelectItem
  • doSelectItemMatching
  • doSelectValue
  • doShowMenu
  • getTitle
  • getValue
  • loadLayout
  • press
  • saveLayout
  • selectItem
  • selectItemMatching
  • setValue
  • show

# 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
Notes None
Examples None
Source src/extensions/cp/ui/MenuButton.lua line 26

# Constructors

# MenuButton

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.axuielement, or nil if it's not available.
Returns
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 39

    # Fields

    # menuUI

    Signature cp.ui.MenuButton.menuUI <cp.prop: hs.axuielement; read-only; live?>
    Type Field
    Description Returns the AXMenu for the MenuButton if it is currently visible.
    Notes None
    Source src/extensions/cp/ui/MenuButton.lua line 80

    # title

    Signature cp.ui.MenuButton.title <cp.prop: string; read-only>
    Type Field
    Description Returns the title for the MenuButton.
    Notes None
    Source src/extensions/cp/ui/MenuButton.lua line 100

    # value

    Signature cp.ui.MenuButton.value <cp.prop: anything>
    Type Field
    Description Returns or sets the current MenuButton value.
    Notes None
    Source src/extensions/cp/ui/MenuButton.lua line 47

    # Methods

    # doPress

    Signature cp.ui.MenuButton:doPress() -> cp.rx.go.Statement
    Type Method
    Description A Statement that presses the MenuButton.
    Parameters
    • None
    Returns
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 311

    # doSelectItem

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 154

    # doSelectItemMatching

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 237

    # doSelectValue

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 170

    # doShowMenu

    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
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 330

    # 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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 254

    # 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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 267

    # loadLayout

    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
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 360

    # press

    Signature cp.ui.MenuButton:press() -> self
    Type Method
    Description Presses the MenuButton.
    Parameters
    • None
    Returns
    • self
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 294

    # saveLayout

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 345

    # selectItem

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 124

    # selectItemMatching

    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.
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 186

    # 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
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 280

    # show

    Signature cp.ui.MenuButton:show() -> self
    Type Method
    Description Show's the MenuButton.
    Parameters
    • None
    Returns
    • self
    Notes None
    Examples None
    Source src/extensions/cp/ui/MenuButton.lua line 107