close

Filter

loading table of contents...

Studio Developer Manual / Version 2406.0

Table Of Contents

9.12 Adding Shortcuts

Once an action is registered in the actionList of a container, a shortcut can easily be applied to it via the AddKeyboardShortcut. Continuing from the example code of the previous section, this looks like follows.

import Config from "@jangaroo/runtime/Config";
import ConfigUtils from "@jangaroo/runtime/ConfigUtils";
import StudioPlugin from "@coremedia/studio-client.main.editor-components/configuration/StudioPlugin";
import AddKeyboardShortcut from "@coremedia/studio-client.main.editor-components/sdk/shortcuts/AddKeyboardShortcut";
import Shortcut_properties from "@coremedia/studio-client.ext.frame-components/shortcuts/Shortcut_properties";

class CustomStudioPlugin extends StudioPlugin {
  static MY_GLOBAL_ACTION_ID:string = "myGlobalAction";

  constructor(config:Config<CustomStudioPlugin> = null){
    super(ConfigUtils.apply(Config(CustomStudioPlugin, {
      configuration: [
        new AddKeyboardShortcut({
          shortcut: Shortcut_properties.Shortcut_my_key,
          description: Shortcut_properties.Shortcut_my_description,
          actionId: CustomStudioPlugin.MY_GLOBAL_ACTION_ID,
        }),
      ],
    }), config));
  }
}

export default CustomStudioPlugin;

The example shows how a shortcut is registered for MyGlobalAction that is already registered.

Shortcuts are defined inside the properties file Shortcut_properties.ts. For customizing existing shortcuts, a properties file has to be created that overrides the Shortcut_properties.ts file via the CopyResourceBundleProperties class.

import resourceManager from "@jangaroo/runtime/l10n/resourceManager";
import CopyResourceBundleProperties from "@coremedia/studio-client.main.editor-components/configuration/CopyResourceBundleProperties";
import Shortcut_properties from "@coremedia/studio-client.ext.frame-components/shortcuts/Shortcut_properties";
import MyCustomShortcuts_properties from "./MyCustomShortcuts_properties";

//...under the 'configuration' property of a StudioPlugin:
new CopyResourceBundleProperties({
  destination: resourceManager.getResourceBundle(null, Shortcut_properties),
  source: resourceManager.getResourceBundle(null, MyCustomShortcuts_properties),
})

To ensure that the documentation for newly created shortcuts is generated automatically and shown in the Studio preferences dialog, the key values inside the properties file must match the following format:

Shortcut_<SHORTCUT_NAME>_key: "<KEY_DEFINITION>",
Shortcut_<SHORTCUT_NAME>_description: "<SHORTCUT_DESCRIPTION>",

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.