UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InputChord.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "CoreTypes.h"
8#include "InputCoreTypes.h"
10#include "Misc/Optional.h"
12
13#include "InputChord.generated.h"
14
15struct FInputChord;
16
17// Was supposed to be deprecated in 4.8, but was never properly marked up
18UE_DEPRECATED(4.21, "Use FInputChord instead of FInputGesture")
20
22USTRUCT(BlueprintType)
24{
26
27
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Key)
30
32 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Modifier)
34
36 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Modifier)
38
40 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Modifier)
42
44 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Modifier)
46
52 {
53 None,
54 Same,
55 Masked,
56 Masks
57 };
58
61
63
65 : Key(InKey)
66 , bShift(false)
67 , bCtrl(false)
68 , bAlt(false)
69 , bCmd(false)
70 {
71 }
72
73 FInputChord(const FKey InKey, const bool bInShift, const bool bInCtrl, const bool bInAlt, const bool bInCmd)
74 : Key(InKey)
76 , bCtrl(bInCtrl)
77 , bAlt(bInAlt)
78 , bCmd(bInCmd)
79 {
80 }
81
89 : Key(InKey)
90 , bShift((InModifierKeys & EModifierKey::Shift) !=0)
91 , bCtrl((InModifierKeys & EModifierKey::Control) != 0)
92 , bAlt((InModifierKeys & EModifierKey::Alt) != 0)
93 , bCmd((InModifierKeys & EModifierKey::Command) != 0)
94 {
95 }
96
104 : Key(InKey)
105 , bShift((InModifierKeys & EModifierKey::Shift) !=0)
106 , bCtrl((InModifierKeys & EModifierKey::Control) != 0)
107 , bAlt((InModifierKeys & EModifierKey::Alt) != 0)
108 , bCmd((InModifierKeys & EModifierKey::Command) != 0)
109 {
110 }
111
117 FInputChord(const FInputChord& Other) = default;
118
125
132
139
146 bool operator==(const FInputChord& Other) const
147 {
148 return ( Key == Other.Key
149 && bShift == Other.bShift
150 && bCtrl == Other.bCtrl
151 && bAlt == Other.bAlt
152 && bCmd == Other.bCmd);
153 }
154
161 bool operator!=( const FInputChord& Other ) const
162 {
163 return !(*this == Other);
164 }
165
166#if PLATFORM_MAC
167 bool NeedsControl() const { return bCmd; }
168 bool NeedsCommand() const { return bCtrl; }
169#else
170 bool NeedsControl() const { return bCtrl; }
171 bool NeedsCommand() const { return bCmd; }
172#endif
173 bool NeedsAlt() const { return bAlt; }
174 bool NeedsShift() const { return bShift; }
175
181 SLATE_API FText GetInputText(const bool bLongDisplayName = true) const;
182
188 SLATE_API FText GetKeyText(const bool bLongDisplayName = true) const;
189
196
202 bool HasAnyModifierKeys( ) const
203 {
204 return (bAlt || bCtrl || bCmd || bShift);
205 }
206
213 bool IsValidChord( ) const
214 {
215 return (Key.IsValid() && !Key.IsModifierKey());
216 }
217
223 {
224 *this = InTemplate;
225 }
226
227public:
228
235 friend uint32 GetTypeHash( const FInputChord& Chord )
236 {
237 return GetTypeHash(Chord.Key) ^ (Chord.bShift | Chord.bCtrl << 1 | Chord.bAlt << 2 | Chord.bCmd << 3);
238 }
239};
240
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Text.h:385
Definition GenericApplication.h:30
uint8 Type
Definition GenericApplication.h:31
@ false
Definition radaudio_common.h:23
Definition InputChord.h:24
bool operator!=(const FInputChord &Other) const
Definition InputChord.h:161
FInputChord(const EModifierKey::Type InModifierKeys, const FKey InKey)
Definition InputChord.h:88
uint32 bAlt
Definition InputChord.h:41
bool NeedsControl() const
Definition InputChord.h:170
bool NeedsAlt() const
Definition InputChord.h:173
SLATE_API FInputChord()
Definition InputChord.cpp:12
FInputChord & operator=(FInputChord &&Other)=default
uint32 bCmd
Definition InputChord.h:45
bool NeedsShift() const
Definition InputChord.h:174
SLATE_API FText GetKeyText(const bool bLongDisplayName=true) const
Definition InputChord.cpp:34
ERelationshipType
Definition InputChord.h:52
bool HasAnyModifierKeys() const
Definition InputChord.h:202
bool IsValidChord() const
Definition InputChord.h:213
SLATE_API FText GetModifierText(TOptional< FText > ModifierAppender=TOptional< FText >()) const
Definition InputChord.cpp:46
void Set(const FInputChord &InTemplate)
Definition InputChord.h:222
FKey Key
Definition InputChord.h:29
bool NeedsCommand() const
Definition InputChord.h:171
friend uint32 GetTypeHash(const FInputChord &Chord)
Definition InputChord.h:235
uint32 bCtrl
Definition InputChord.h:37
uint32 bShift
Definition InputChord.h:33
FInputChord(const FKey InKey, const EModifierKey::Type InModifierKeys)
Definition InputChord.h:103
FInputChord & operator=(const FInputChord &Other)=default
bool operator==(const FInputChord &Other) const
Definition InputChord.h:146
FInputChord(FInputChord &&Other)=default
SLATE_API FText GetInputText(const bool bLongDisplayName=true) const
Definition InputChord.cpp:24
FInputChord(const FInputChord &Other)=default
FInputChord(const FKey InKey, const bool bInShift, const bool bInCtrl, const bool bInAlt, const bool bInCmd)
Definition InputChord.h:73
SLATE_API ERelationshipType GetRelationship(const FInputChord &OtherChord) const
Definition InputChord.cpp:106
FInputChord(const FKey InKey)
Definition InputChord.h:64
Definition InputCoreTypes.h:50
INPUTCORE_API bool IsModifierKey() const
Definition InputCoreTypes.cpp:1314
INPUTCORE_API bool IsValid() const
Definition InputCoreTypes.cpp:1294
Definition Optional.h:131