UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DragAndDrop.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 "Input/CursorReply.h"
7#include "Input/Events.h"
8
9class SWidget;
10class SWindow;
11
20 : public TSharedFromThis<FDragDropOperation>
21{
22public:
23
28
33
35 template<class TType> bool IsOfType() const
36 {
37 return IsOfTypeImpl(TType::GetTypeId());
38 }
39
46 virtual bool AffectedByPointerEvent(const FPointerEvent& PointerEvent) {return true;}
47
54 SLATECORE_API virtual void OnDrop( bool bDropWasHandled, const FPointerEvent& MouseEvent );
55
61 SLATECORE_API virtual void OnDragged( const class FDragDropEvent& DragDropEvent );
62
65
71
73 virtual FVector2D GetDecoratorPosition() const { return FVector2D(0, 0); }
74
76 SLATECORE_API virtual void SetDecoratorVisibility(bool bVisible);
77
79 virtual bool IsExternalOperation() const { return false; }
80
82 virtual bool IsWindowlessOperation() const { return bCreateNewWindow == false; }
83
90
94 virtual bool IsOfTypeImpl(const FString& Type) const
95 {
96 return false;
97 }
98protected:
99
103 SLATECORE_API virtual void Construct();
104
109
114
115 virtual TSharedPtr<FDragDropOperation> ConvertTo(const FString& TypeId)
116 {
118 }
119
120protected:
121
127
130
133
136};
137
138
141{
142public:
154
157 {
158 return Content;
159 }
160
162 template<typename OperationType>
164
165private:
168};
169
170
180 bool /* bWasDropHandled */,
181 const FDragDropEvent& /* DragDropEvent */
182)
183
184
191 const FDragDropEvent& /* DragDropEvent */
192)
193
194
195
196
207#define DRAG_DROP_OPERATOR_TYPE(TYPE, BASE) \
208 static const FString& GetTypeId() { static FString Type = TEXT(#TYPE); return Type; } \
209 virtual bool IsOfTypeImpl(const FString& Type) const override { return GetTypeId() == Type || BASE::IsOfTypeImpl(Type); }
210
211
217{
218private:
221
222 virtual bool IsExternalOperation() const override { return true; }
223
224public:
226
227
233
235 bool HasText() const {return !!(DragType & DragText);}
237 bool HasFiles() const {return !!(DragType & DragFiles);}
238
240 const FString& GetText() const { ensure(HasText()); return DraggedText;}
242 const TArray<FString>& GetFiles() const { ensure(HasFiles()); return DraggedFileNames;}
243
244private:
245 FString DraggedText;
246 TArray<FString> DraggedFileNames;
247
248 enum EExternalDragType
249 {
250 DragText = 1<<0,
251 DragFiles = 1<<1,
252 };
253 uint8 DragType;
254};
255
256
273
274#include "Input/DragAndDrop.inl" // IWYU pragma: export
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:57
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
#define DRAG_DROP_OPERATOR_TYPE(TYPE, BASE)
Definition DragAndDrop.h:207
UE::Math::TVector2< double > FVector2D
Definition MathFwd.h:48
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition CursorReply.h:16
Definition DragAndDrop.h:141
FDragDropEvent(const FPointerEvent &InMouseEvent, const TSharedPtr< FDragDropOperation > InContent)
Definition DragAndDrop.h:149
TSharedPtr< FDragDropOperation > GetOperation() const
Definition DragAndDrop.h:156
TSharedPtr< OperationType > GetOperationAs() const
Definition DragAndDrop.inl:9
Definition DragAndDrop.h:21
virtual SLATECORE_API FCursorReply OnCursorQuery()
Definition DragAndDrop.cpp:49
SLATECORE_API FDragDropOperation()
Definition DragAndDrop.cpp:12
virtual bool IsExternalOperation() const
Definition DragAndDrop.h:79
virtual bool IsWindowlessOperation() const
Definition DragAndDrop.h:82
virtual SLATECORE_API void OnDragged(const class FDragDropEvent &DragDropEvent)
Definition DragAndDrop.cpp:31
bool IsOfType() const
Definition DragAndDrop.h:35
SLATECORE_API void CreateCursorDecoratorWindow()
Definition DragAndDrop.cpp:112
virtual TSharedPtr< SWidget > GetDefaultDecorator() const
Definition DragAndDrop.h:70
virtual SLATECORE_API ~FDragDropOperation()
Definition DragAndDrop.cpp:17
virtual FVector2D GetDecoratorPosition() const
Definition DragAndDrop.h:73
virtual SLATECORE_API void Construct()
Definition DragAndDrop.cpp:104
virtual bool AffectedByPointerEvent(const FPointerEvent &PointerEvent)
Definition DragAndDrop.h:46
SLATECORE_API void SetCursorOverride(TOptional< EMouseCursor::Type > CursorType)
Definition DragAndDrop.cpp:95
SLATECORE_API void DestroyCursorDecoratorWindow()
Definition DragAndDrop.cpp:125
virtual SLATECORE_API void OnDrop(bool bDropWasHandled, const FPointerEvent &MouseEvent)
Definition DragAndDrop.cpp:26
bool bCreateNewWindow
Definition DragAndDrop.h:126
TOptional< EMouseCursor::Type > MouseCursor
Definition DragAndDrop.h:132
virtual SLATECORE_API void SetDecoratorVisibility(bool bVisible)
Definition DragAndDrop.cpp:64
virtual TSharedPtr< FDragDropOperation > ConvertTo(const FString &TypeId)
Definition DragAndDrop.h:115
TOptional< EMouseCursor::Type > MouseCursorOverride
Definition DragAndDrop.h:135
virtual bool IsOfTypeImpl(const FString &Type) const
Definition DragAndDrop.h:94
TSharedPtr< SWindow > CursorDecoratorWindow
Definition DragAndDrop.h:129
Definition DragAndDrop.h:217
static SLATECORE_API TSharedRef< FExternalDragOperation > NewText(FString InText)
Definition DragAndDrop.cpp:138
const FString & GetText() const
Definition DragAndDrop.h:240
const TArray< FString > & GetFiles() const
Definition DragAndDrop.h:242
static SLATECORE_API TSharedRef< FExternalDragOperation > NewFiles(TArray< FString > InFileNames)
Definition DragAndDrop.cpp:147
bool HasFiles() const
Definition DragAndDrop.h:237
bool HasText() const
Definition DragAndDrop.h:235
static SLATECORE_API TSharedRef< FExternalDragOperation > NewOperation(FString InText, TArray< FString > InFileNames)
Definition DragAndDrop.cpp:156
Definition DragAndDrop.h:258
virtual SLATECORE_API FVector2D GetDecoratorPosition() const override
Definition DragAndDrop.cpp:176
SLATECORE_API FGameDragDropOperation()
Definition DragAndDrop.cpp:170
FVector2D DecoratorPosition
Definition DragAndDrop.h:271
Definition SWidget.h:165
Definition SWindow.h:243
Definition Array.h:670
Definition SharedPointer.h:1640
TSharedRef< FDragDropOperation, Mode > AsShared()
Definition SharedPointer.h:1650
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition Events.h:695
Definition Optional.h:131