Not quite sure if this is an easy task. In my Widgets, I am able to move around the buttons using the keys on my keyboard (Up, down, left, right arrows), now, to press on a button, you can do so by pressing enter or spacebar. However, the spacebar is connected to another action and I cannot have it activate the press of that button. This is however automatically there at default, is there a particular way to remap which keys can do what in your UI navigation?
This could also make WASD navigation between buttons possible or pressing Y on a gamepad to activate a button instead of A and so on.
I haven’t found a way to do it since, but for my particular problem, I just disabled the input on another function that would usually be activated. It would still be useful to know how to remap these though!
Basically it will block the enter and space bar input in the entire widget, but on the true line you can call any function or custom event and run that with the key you wanted.
include “CoreMinimal.h”
include “GameFramework/GameModeBase.h”
include “Framework/Application/SlateApplication.h”
include “Framework/Application/NavigationConfig.h”
include “MyGameModeBase.generated.h”
// Custom Navigation Config class declaration
class FCustomNavigationConfig : public FNavigationConfig
{
public:
FCustomNavigationConfig()
{
// Map WASD to navigate like arrow keys
KeyEventRules.Emplace(EKeys::W, EUINavigation::Up);
KeyEventRules.Emplace(EKeys::S, EUINavigation::Down);
KeyEventRules.Emplace(EKeys::A, EUINavigation::Left);
KeyEventRules.Emplace(EKeys::D, EUINavigation::Right);
}
};
UCLASS()
class FALKEGG2_API AMyGameModeBase : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
};
------ HEADER -----------
include “MyGameModeBase.h”
include “Framework/Application/SlateApplication.h”
include “Framework/Application/NavigationConfig.h”