WB_Hotkeys redesigned to use enhanced input. Amazing!

This commit is contained in:
2026-04-17 02:18:30 -04:00
parent 26399a6a15
commit ae1ad7640d
10 changed files with 169 additions and 11 deletions

View File

@@ -0,0 +1,50 @@
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "EnhancedInputComponent.h"
#include "LuprexUserWidget.generated.h"
UCLASS(BlueprintType, Blueprintable)
class INTEGRATION_API UlxUserWidget : public UUserWidget
{
GENERATED_BODY()
public:
using EventBinding = TUniquePtr<FEnhancedInputActionEventBinding>;
UlxUserWidget(const FObjectInitializer& ObjectInitializer);
virtual void NativeOnInitialized() override;
// Clone every enhanced-input action binding currently on InputComponent
// into SavedEnhancedActionEventBindings, so bindings can later be removed
// from the component and reinstated without losing their delegates.
void BackupInputComponent();
// Remove every live event binding whose action is InputAction.
// No-op if there are none, or if InputComponent isn't enhanced.
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
void DisableEventBinding(const UInputAction* InputAction);
// Replace any live bindings for InputAction with fresh clones of every
// saved binding for that action. Leaves the backup array intact so this
// can be called repeatedly.
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
void RestoreInputBinding(const UInputAction* InputAction);
// Install live bindings on From that, when fired, dispatch through a
// clone of each saved binding for To. Clears any pre-existing live
// bindings on From first. Backup array is untouched.
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
void RedirectInputAction(const UInputAction* From, const UInputAction* To);
// Cloned bindings captured from InputComponent after construction.
TArray<EventBinding> SavedEnhancedActionEventBindings;
private:
// Strip the synthetic const off UEnhancedInputComponent::GetActionEventBindings
// to get direct mutable access to the protected array. Well-defined because
// the underlying object is not const; only the getter's return type is.
static TArray<EventBinding>& GetMutableActionEventBindings(UEnhancedInputComponent* EIC);
};