Still working on event handling for hotkey widgets
This commit is contained in:
54
Source/Integration/StoreFNameInputModifier.h
Normal file
54
Source/Integration/StoreFNameInputModifier.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "InputModifiers.h"
|
||||
#include "StoreFNameInputModifier.generated.h"
|
||||
|
||||
/**
|
||||
* @brief Allows you to pass an FName into an event handler.
|
||||
*
|
||||
* This modifier allows you to type an FName directly into an input mapping in
|
||||
* the InputMappingContext editor, and have that FName passed through to an
|
||||
* enhanced input handler.
|
||||
*
|
||||
* This modifier has an FName UPROPERTY which is editable in the InputMappingContext
|
||||
* editor. At runtime, it encodes the FName as an Axis3D. In the event handler,
|
||||
* the Axis3D can be decoded back into an FName using DecodeFNameFromAxis3D.
|
||||
*
|
||||
* One use for this modifier is when you want to know exactly which
|
||||
* keyboard key triggered an EnhancedInput event. You can put the key's FName
|
||||
* into the InputMappingContext, and it will get passed through to the event
|
||||
* handler.
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class INTEGRATION_API UPassFNameAsAxis3D : public UInputModifier
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief The FName to be encoded into the FInputActionValue.
|
||||
*
|
||||
* This property can be configured in the Input Mapping Context editor
|
||||
* for each specific mapping.
|
||||
*
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Modifier Settings")
|
||||
FName FNameToStore;
|
||||
|
||||
protected:
|
||||
virtual FInputActionValue ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime) override;
|
||||
|
||||
/**
|
||||
* @brief Decodes an FName that was passed by the PassFnameAsAxis3D modifier.
|
||||
*
|
||||
* This function is used in an enhanced input event, where the PassFNameAsAxis3D
|
||||
* modifier was used to pass an FName into the event. The value shows up as
|
||||
* an Axis3D, which much be decoded back into an FName.
|
||||
*
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Input|Enhanced")
|
||||
static FName DecodeFNameFromAxis3D(const FVector& Encoded);
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user