is there any workaround for this?
Where are you expecting the key event? On the Widget? PlayerController? Pawn?
Is it an input mapping event or an overriden method handling input?
widget, but if it worked anywhere else I could route it to the widget. except it doesn’t work anywhere I tested when input mode is set to UI. it’s just the navigation keys though, other keys work just fine.
I’m setting up keyboard/gamepad menu navigation, and I wanted to check button focus on navigation input instead of on tick or a timer.
So yeah it doesn’t matter where I put the arrow key event, I tried player controller, character, widget, whatever, if input mode is set to UI only or game+ui, it won’t trigger.
I’m guessing this is by design? is there a workaround?
I never noticed this… Slate navigation uses the arrow key for its built-in widget navigation, not sure if that is the conflict you are experiencing.
On the widget you could override the function OnKeyDown and test if the pressed key is key up like this:
Here you should normally implement the input as an input mapping (Project settings : ActionMapping / AxisMapping) . Can you test this for me?
it works in game+ui, as long as you don’t have a widget on focus.
I added both arrow up and W keys to a single input action, and if you’re focusing on a widget, only the W key will fire the input action, arrow key will navigate the widget and not fire anything (from any blueprints, not just widget but also player controller, character, etc). I suppose this is by design, but it makes a bit clunky to set up custom navigation (such as overriding on key down as you suggested, but with a branch for each key you need)
regardless, the override works for what I need, so thank you!
Is your problem solved for now?
In C++ you can override conflicting Slate input by implementing a custom config:
FSlateApplication::Get().SetNavigationConfig(TSharedRef<FCustomSlateNavigationConfig>(new FCustomSlateNavigationConfig()));
In that custom config you can define the navigation and actions of slate and their keys.
to be honest nope, not solved yet…
navigation keys won’t even trigger the “OnKeyDown” override.
I’m not familiar at all with C++, but if there’s no other way, where should I add that code?
Ah, well the c++ thing isn’t a 2 step process. First you create a new class:
.h
#pragma once
#include "Framework/Application/NavigationConfig.h"
class FCustomSlateNavigationConfig : public FNavigationConfig {
public:
FCustomSlateNavigationConfig();
};
.cpp
#include "CustomSlateNavigationConfig.h"
FCustomSlateNavigationConfig::FCustomSlateNavigationConfig() {
KeyEventRules.Empty();
// Add your own KeyEventRules in the KeyEventRules array
}
Then from another place, like your module’s .cpp file you could override Slate’s navigation with the custom one like this:
FSlateApplication::Get().SetNavigationConfig(TSharedRef<FCustomSlateNavigationConfig>(new FCustomSlateNavigationConfig()));
I have heavily modified my stuff, haven’t checked what the arrow key should behave like on a clean project, that’s one thing you can still try before deep diving into code.
I’m on an empty project, so this is default behavior, when input mode is set to “UI only” or “Game + UI” the arrow keys, d-pad buttons, or any keys used for UI navigation by default simply don’t trigger any action input.
I don’t really want to change my navigation keys, all I want is the game to be able to recognize input method (keyboard+mouse or gamepad) when I’m in UI input mode, so when I’m navigating a menu, the game recognizes if I’m using a keyboard or a gamepad, and I can display the proper button icon.
to
for example.
but when navigation keys don’t trigger anything, not even “on key down” events to override, it becomes impossible to do so.
Not impossible, you can still detect the input device through an input processor and work from there.
thank you again, I really believe this could be a solution.
however, being mostly a 3d artists who took a while to learn blueprint, I have absolutely 0 experience with C++ or how to implement it in unreal. I literally don’t know where I should put this code, or what to change if I had to change anything.
perhaps you could point me directions to figure this out?
It’s not a two step process but the code from that Github link does the input device registration already. What remains is that you need basic knowledge of c++ yourself and learn how to use Visual Studio (because the source code needs to be compiled afterwards). After that you still have to write the implementation for the UI system to respond to the input changes and all. You’d best be doing a few UE c++ tutorials and mess with it if you want to .