Keyboard Shortcuts in Standard Buttons

Overview

In the Standard UI system, we now enable buttons to specify input actions that will act as clicking the button. If the button is enabled and on the screen, pressing the associated key will trigger the button.

The buttons can either be assigned bespoke to a given button In WBP_M2_StandardButton /M2_StandardButtonData, or a set of keys can be automatically assigned In button lists.

This uses Input Icons to display shortcut keys for given input actions.

How to add

Live config

To enable/disable shortcuts in standard UI elements (e.g. the interaction menu and the gadgets' menus), you need the StandardUI.ShortcutsEnabled flag.

In WBP_M2_StandardButton /M2_StandardButtonData

If you have an individual M2_StandardButtonData that you want to assign a keyboard shortcut for (e.g if you are adding a WBP_M2_StandardButton directly to your screen), you can do so by setting the "Shortcuts" data within the object.

The fields are as follows:

  • ShortcutMappingContext and ShortcutAction:

    • These are required for specifying the "Enhanced Input" action and mapping used to identify what key should be pressed.

  • ShortcutIconLeftAligned:

    • This determines whether the shortcut icon appears on the left or the right of the button.

    • NOTE: If left-aligned, the icon is treated as a "visual attachment", so isn't treated as part of the widget when it comes to spacing or the like. This is so that we can have consistently aligned buttons in a list where some buttons don't have icons.

  • ShortcutPrioritizationName and ShortcutPrioritizationPriority:

    • These are optional fields you can add to make your shortcut use the Input Prioritization System (Input Prioritization).

    • (If you don't want to use the Input Prioritization System, leave ShortcutPrioritizationName as None)

    • Note: When using the input prioritization system, you need to make sure the inputs are set to not consume - that way we can listen to all the inputs, and handle them according to their priority

In button lists

If you have a list of buttons, which could have arbitrary buttons in them, but you want to assign a consistent set of shortcuts, you can configure this using the WBP_M2_StandardButtonList

The fields are as follows:

  • ShortcutMappingContext:

    • The mapping used for all the shortcuts in the list.

  • ShortcutActionList:

    • The actions we'll assign to the buttons in the list.

    • If we have more buttons than entries in the list, the surplus buttons won't have shortcut keys.

    • NOTE: If there are shortcuts already assigned in the button data in the list, one of two things will happen:

      • If the shortcuts are one of those already in this list, they will be overridden.

      • If the shortcuts are different actions, they will be ignored. (e.g. if you have actions for E, R, T and Y defined in your ShortcutActionList, but have a button data entry that specifies a "Left click" shortcut, that button will remain, and E, R, T and Y will be assigned to the other buttons in the list.

  • FlipList:

    • Means that we assign the shortcuts from the bottom up, rather than top down. You can use this if you want to have buttons follow a different order stylistically.

  • ShortcutPrioritizationName/ShortcutPrioritizationPriority/LeftAlignShortcutIcons: Same as for M2_StandardButtonData.

Updating the shortcut dynamically

From the button data, you can call UpdateShortcutInfo to update the shortcut info used, e.g. by supplying a new mapping context and input action, or removing the shortcut

Last updated