GridCraft.Grid

A grid of hotkeys.

API Overview #

  • Constructors - API calls which return an object, typically one that offers API methods
  • Methods - API calls which can only be made on an object returned by a constructor

API Documentation #

Constructors #

new #

SignatureGridCraft.Grid.new(table, string, table, string) -> table
TypeConstructor
Description

Create a new grid of hotkeys

Parameters
  • mods: Modifier keys as could be4 passed to hs.hotkey.modal.new(), like {"cmd", "ctrl"} or {}
  • key: A key to trigger the modal hotkey as could be passed to hs.hotkey.modal.new(), like t
  • actionTable: (table) A table of rows, each of which is a table of actions. e.g. to represent the left half of a qwerty keyboard, you might use:
    {
      {
        GridCraft.handler { key = "1", application = "1Password" },
        GridCraft.handler { key = "2", application = "Day One" },
        GridCraft.handler { key = "3", application = "Photos" },
        GridCraft.handler { key = "4", empty = true },
        GridCraft.handler { key = "5", empty = true },
      },
      {
        GridCraft.handler { key = "q", application = "Messages"},
        GridCraft.handler { key = "w", application = "Mattermost" },
        GridCraft.handler { key = "e", application = "Visual Studio Code" },
        GridCraft.handler { key = "r", application = "Bear" },
        GridCraft.handler { key = "t", application = "Terminal" },
      },
    }
    
    Note that we are constrained to using array tables rather than key-value tobles so that the order is preserved.
  • title: (string) (optional) A message prefix to display when communicating to the user about this hot key
  • config: (GridCraft.Configuration) (optional) A configuration object for the grid.
Returns
  • A GridCraft grid of hotkeys

Methods #

applyConfiguration #

SignatureGridCraft.Grid:applyConfiguration()
TypeMethod
Description

Apply the configuration to the grid.

Notes
  • This is run when the grid is created and when setConfiguration() is called, and makes sure that the configuration is applied to the web view, all submenus, etc.

setConfig #

SignatureGridCraft.Grid:setConfig(config)
TypeMethod
Description

Set the configuration for the grid.

Parameters
  • config - A GridCraft.Configuration object containing the configuration for the grid
Returns
  • The grid object itself, for chaining
Notes
  • Mutates the existing grid object, so that all references in closures will get the new values.
  • Sets the configuration on all submenus as well.
  • Use this method instead of changing the .config field directly.