Jun 22, 2021.Knowledge
Slate defines some default navigation key mappings in FNavigationConfig, which is used by most Slate widgets to process input events and translate them to directional inputs or accept/cancel actions. For example, both the Enter and Spacebar key, as well as the Virtual_Accept gamepad key (usually mapped to the bottom face button), are translated to an EUINavigationAction::Accept action:
EUINavigationAction FNavigationConfig::GetNavigationActionForKey(const FKey& InKey) const
if (InKey == EKeys::Enter || InKey == EKeys::SpaceBar || InKey == EKeys::Virtual_Accept)
// By default, enter, space, and gamepad accept are all counted as accept
else if (InKey == EKeys::Escape || InKey == EKeys::Virtual_Back)
// By default, escape and gamepad back count as leaving current scope
It’s possible to customize the mappings used for these actions by registering your own navigation class. First, you’ll override FNavigationConfig and implement whichever functions you want to modify (GetNavigationDirectionFromKey, GetNavigationActionFromKey, etc.) Then, you’ll provide your navigation config file to SlateApplication via FSlateApplication::SetNavigationConfig.
Note that the editor maintains two separate FNavigationConfig instances, one for the editor and one for gameplay. This prevents changes to runtime navigation controls from affecting the editor.