The way I managed to work around this issue is to create a subclass of FNavigationConfig
and to set it using FSlateApplication::Get().SetNavigationConfig(NavigationConfig);
.
In my subclass, I overrode some methods such as virtual EUINavigation GetNavigationDirectionFromKey(const FKeyEvent& InKeyEvent) const override;
that returns EUINavigation::Invalid
when I disabled navigation.
You can also define your “mappings” for instance, the default is:
FNavigationConfig::FNavigationConfig()
: bTabNavigation(true)
, bKeyNavigation(true)
, bAnalogNavigation(true)
, bIgnoreModifiersForNavigationActions(true)
, AnalogNavigationHorizontalThreshold(0.50f)
, AnalogNavigationVerticalThreshold(0.50f)
{
AnalogHorizontalKey = EKeys::Gamepad_LeftX;
AnalogVerticalKey = EKeys::Gamepad_LeftY;
KeyEventRules.Emplace(EKeys::Left, EUINavigation::Left);
KeyEventRules.Emplace(EKeys::Gamepad_DPad_Left, EUINavigation::Left);
KeyEventRules.Emplace(EKeys::Right, EUINavigation::Right);
KeyEventRules.Emplace(EKeys::Gamepad_DPad_Right, EUINavigation::Right);
KeyEventRules.Emplace(EKeys::Up, EUINavigation::Up);
KeyEventRules.Emplace(EKeys::Gamepad_DPad_Up, EUINavigation::Up);
KeyEventRules.Emplace(EKeys::Down, EUINavigation::Down);
KeyEventRules.Emplace(EKeys::Gamepad_DPad_Down, EUINavigation::Down);
// By default, enter, space, and gamepad accept are all counted as accept
KeyActionRules.Emplace(EKeys::Enter, EUINavigationAction::Accept);
KeyActionRules.Emplace(EKeys::SpaceBar, EUINavigationAction::Accept);
KeyActionRules.Emplace(EKeys::Virtual_Accept, EUINavigationAction::Accept);
// By default, escape and gamepad back count as leaving current scope
KeyActionRules.Emplace(EKeys::Escape, EUINavigationAction::Back);
KeyActionRules.Emplace(EKeys::Virtual_Back, EUINavigationAction::Back);
}
But the engine also offers an alternate nav config with a subclass defining its own rules (and a good place to learn more about the Navigation config):
FTwinStickNavigationConfig::FTwinStickNavigationConfig()
{
bTabNavigation = false;
KeyEventRules =
{
{EKeys::Gamepad_DPad_Left, EUINavigation::Left},
{EKeys::Gamepad_DPad_Right, EUINavigation::Right},
{EKeys::Gamepad_DPad_Up, EUINavigation::Up},
{EKeys::Gamepad_DPad_Down, EUINavigation::Down}
};
}