(actionName, handler, options)
| 394 | * } |
| 395 | */ |
| 396 | export function registerAction(actionName, handler, options) { |
| 397 | options = impliedOptions(options); |
| 398 | |
| 399 | const { |
| 400 | settings, |
| 401 | opensNavigator, |
| 402 | } = options; |
| 403 | |
| 404 | let mutterName, keyHandler; |
| 405 | if (settings) { |
| 406 | Utils.assert(actionName, "Schema action must have a name"); |
| 407 | mutterName = actionName; |
| 408 | keyHandler = opensNavigator |
| 409 | ? asKeyHandler(Navigator.preview_navigate) |
| 410 | : asKeyHandler(handler); |
| 411 | } else { |
| 412 | // actionId, mutterName and keyHandler will be set if/when the action is bound |
| 413 | } |
| 414 | |
| 415 | const action = { |
| 416 | id: Meta.KeyBindingAction.NONE, |
| 417 | name: actionName, |
| 418 | mutterName, |
| 419 | keyHandler, |
| 420 | handler, |
| 421 | options, |
| 422 | }; |
| 423 | |
| 424 | actions.push(action); |
| 425 | if (actionName) |
| 426 | nameMap[actionName] = action; |
| 427 | |
| 428 | return action; |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Bind a key to an action (possibly creating a new action) |
no test coverage detected