Hotkeys Managers
#
OverviewHotkeysManager
handles all the logics for adding, setting and enabling/disabling
the hotkeys.
#
InstantiationHotkeysManager
is instantiated in the appInit
similar to the other managers.
const commandsManager = new CommandsManager(commandsManagerConfig);const servicesManager = new ServicesManager(commandsManager);const hotkeysManager = new HotkeysManager(commandsManager, servicesManager);const extensionManager = new ExtensionManager({ commandsManager, servicesManager, hotkeysManager, appConfig,});
#
Hotkeys Manager APIsetHotkeys
: The most important method in theHotkeysManager
which binds the keys with commands.setDefaultHotKeys
: set the defaultHotkeys property. Note that, this method does not bind the provided hotkeys; however, whenrestoreDefaultBindings
is called, the provided defaultHotkeys will get binded.destroy
: reset the HotkeysManager, and remove the set hotkeys and empty out thedefaultHotkeys
#
Structure of a Hotkey DefinitionA hotkey definition should have the following properties:
commandName
: name of the registered commandcommandOptions
: extra arguments to the commandskeys
: an array defining the key to get binded to the commandlabel
: label to be shown in the hotkeys preference panelisEditable
: whether the key can be edited by the user in the hotkey panel
#
Default hotkeysBindingsThe default key bindings can be find in hotkeyBindings.js
// platform/core/src/defaults/hotkeyBindings.js
export default [ /**..**/ { commandName: 'setToolActive', commandOptions: { toolName: 'Zoom' }, label: 'Zoom', keys: ['z'], isEditable: true, },
{ commandName: 'flipViewportHorizontal', label: 'Flip Vertically', keys: ['v'], isEditable: true, }, /**..**/]
#
Behind the SceneWhen you setHotkeys
, the commandName
gets registered with the commandsManager
and
get run after the key is pressed.