Agrarsense
Public Member Functions | List of all members
SDragAndDropWidget Class Reference

#include <DragAndDropWidget.h>

Inheritance diagram for SDragAndDropWidget:
Inheritance graph
[legend]
Collaboration diagram for SDragAndDropWidget:
Collaboration graph
[legend]

Public Member Functions

 SLATE_BEGIN_ARGS (SDragAndDropWidget)
 
void Construct (const FArguments &InArgs)
 
FReply OnDragOver (const FGeometry &MyGeometry, const FDragDropEvent &DragDropEvent) override
 
FReply OnDrop (const FGeometry &MyGeometry, const FDragDropEvent &DragDropEvent) override
 

Detailed Description

A custom widget for handling drag-and-drop in Unreal Engine's runtime viewport.

Definition at line 15 of file DragAndDropWidget.h.

Member Function Documentation

◆ Construct()

void SDragAndDropWidget::Construct ( const FArguments &  InArgs)

Definition at line 10 of file DragAndDropWidget.cpp.

11{
12
13}

◆ OnDragOver()

FReply SDragAndDropWidget::OnDragOver ( const FGeometry &  MyGeometry,
const FDragDropEvent &  DragDropEvent 
)
override

Definition at line 15 of file DragAndDropWidget.cpp.

16{
17 TSharedPtr<FExternalDragOperation> DragDropOp = DragDropEvent.GetOperationAs<FExternalDragOperation>();
18 if (DragDropOp.IsValid() && DragDropOp->HasFiles())
19 {
20 // For below OnDrop to work, Handled must be returned here.
21 return FReply::Handled();
22 }
23
24 return FReply::Unhandled();
25}

◆ OnDrop()

FReply SDragAndDropWidget::OnDrop ( const FGeometry &  MyGeometry,
const FDragDropEvent &  DragDropEvent 
)
override

Definition at line 27 of file DragAndDropWidget.cpp.

28{
29 SCompoundWidget::OnDrop(MyGeometry, DragDropEvent);
30
31 TSharedPtr<FExternalDragOperation> DragDropOp = DragDropEvent.GetOperationAs<FExternalDragOperation>();
32 if (DragDropOp.IsValid() && DragDropOp->HasFiles())
33 {
34 const TArray<FString>& Files = DragDropOp->GetFiles();
35 for (const FString& File : Files)
36 {
37#if WITH_EDITOR
38 UE_LOG(LogTemp, Log, TEXT("Dropped file to window. Path: %s"), *File);
39#endif
40
41 if (FPaths::GetExtension(File).Equals(TEXT("json"), ESearchCase::IgnoreCase))
42 {
43 // Attempt to spawn objects defined in .json file using USimulatorJsonParser
45 }
46 }
47
48 return FReply::Handled();
49 }
50
51 return FReply::Unhandled();
52}
static void ParseAndOperateJSONFile(const FString &Path)

References USimulatorJsonParser::ParseAndOperateJSONFile().

◆ SLATE_BEGIN_ARGS()

SDragAndDropWidget::SLATE_BEGIN_ARGS ( SDragAndDropWidget  )
inline

Definition at line 20 of file DragAndDropWidget.h.

20{}

The documentation for this class was generated from the following files: