# Drop an array of objects on a Slate Graph

**URL:** <https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116>\
**Category:** UI\
**Tags:** drop, drag-and-drop, unreal-engine, Array, slate, question\
**Created:** [September 8, 2017, 6:47pm UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116 "2017-09-08T18:47:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![turbocheke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/turbocheke/32/1186254_2.png) [@turbocheke](https://forums.unrealengine.com/u/turbocheke)\
**Post date:** [September 8, 2017, 6:47pm UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116/1 "2017-09-08T18:47:52Z")

</div>

I am working on a Slate Graph, I can drop a Texture as i like and get the node, now I like to Drop a selection of Objects(Textures on this case), to simplify the work of selection. How it can be possible?  
I am Using the class SAssetDropTarget with the delegates .OnAssetDropped and .OnIsAssetAcceptableForDrop, trying so many things who doesnt work, now I will log wath happens when I try to drop an selection.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [September 8, 2017, 7:25pm UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116/2 "2017-09-08T19:25:32Z")

</div>

OnIsAssetAcceptableForDrop sounds like compatibility check event, it should return to true to let asset drop. Did you do that?

---

<div class="post-metadata">

**Author:** ![turbocheke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/turbocheke/32/1186254_2.png) [@turbocheke](https://forums.unrealengine.com/u/turbocheke)\
**Post date:** [September 8, 2017, 7:49pm UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116/3 "2017-09-08T19:49:37Z")

</div>

I check the event, only works if the drag is individual, not work and dont release never if is a selection of assets

---

<div class="post-metadata">

**Author:** ![turbocheke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/turbocheke/32/1186254_2.png) [@turbocheke](https://forums.unrealengine.com/u/turbocheke)\
**Post date:** [September 8, 2017, 7:58pm UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116/4 "2017-09-08T19:58:37Z")

</div>

I try to figure out with Logs wath happens when I have selected some assets on the Content Browser and I try to Drop on the Graph,do nothing, OnIsAssetAcceptableForDrop is never called. I think is a limitation on the class, I think I need to implement new functions based on DragAnDrop.h

---

<div class="post-metadata">

**Author:** ![turbocheke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/turbocheke/32/1186254_2.png) [@turbocheke](https://forums.unrealengine.com/u/turbocheke)\
**Post date:** [September 9, 2017, 2:38am UTC](https://forums.unrealengine.com/t/drop-an-array-of-objects-on-a-slate-graph/404116/5 "2017-09-09T02:38:58Z")

</div>

I resolved as I Think preliminary; on SAssetDropTarget an internal function only was processed if only drops one UObject I Modify by my needs.  
For me Works good, if I found a bug I will release here the fix.

```
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

#include "SAssetDropTargetArray.h"
#include "AssetData.h"
#include "DragAndDrop/AssetDragDropOp.h"
#include "DragAndDrop/ActorDragDropOp.h"
#include "AssetSelection.h"

#define LOCTEXT_NAMESPACE "EditorWidgets"

void SAssetDropTargetArray::Construct(const FArguments& InArgs)
{
	OnAssetDropped = InArgs._OnAssetDropped;
	OnIsAssetAcceptableForDrop = InArgs._OnIsAssetAcceptableForDrop;

	SDropTarget::Construct(
		SDropTarget::FArguments()
		.OnDrop(this, &SAssetDropTargetArray::OnDropped)
		[
			InArgs._Content.Widget
		]);
}

FReply SAssetDropTargetArray::OnDropped(TSharedPtr<FDragDropOperation> DragDropOperation)
{
	bool bUnused;
	TArray<UObject*> Objects = GetDroppedObject(DragDropOperation, bUnused);
	for (UObject* Object :Objects)
	{
		OnAssetDropped.ExecuteIfBound(Object);
	}

	return FReply::Handled();
}

bool SAssetDropTargetArray::OnAllowDrop(TSharedPtr<FDragDropOperation> DragDropOperation) const
{
	bool bUnused = false;
	TArray<UObject*> Objects = GetDroppedObject(DragDropOperation, bUnused);
	for (UObject* Object : Objects)
	{
		// Check and see if its valid to drop this object
		if (OnIsAssetAcceptableForDrop.IsBound())
		{
			return OnIsAssetAcceptableForDrop.Execute(Object);
		}
		else
		{
			// If no delegate is bound assume its always valid to drop this object
			return true;
		}
	}

	return false;
}

bool SAssetDropTargetArray::OnIsRecognized(TSharedPtr<FDragDropOperation> DragDropOperation) const
{
	bool bRecognizedEvent = false;
	TArray<UObject*> Object = GetDroppedObject(DragDropOperation, bRecognizedEvent);

	return bRecognizedEvent;
}

TArray<UObject*> SAssetDropTargetArray::GetDroppedObject(TSharedPtr<FDragDropOperation> DragDropOperation, bool& bOutRecognizedEvent) const
{
	bOutRecognizedEvent = false;
	TArray<UObject*> DropppedArray;
	
	// Asset being dragged from content browser
	if (DragDropOperation->IsOfType<FAssetDragDropOp>())
	{
		bOutRecognizedEvent = true;
		TSharedPtr<FAssetDragDropOp> DragDropOp = StaticCastSharedPtr<FAssetDragDropOp>(DragDropOperation);
		const TArray<FAssetData>& DroppedAssets = DragDropOp->GetAssets();
		if (DroppedAssets.Num() < 1)
		{
			return DropppedArray;
		}
		for (FAssetData AssetData : DroppedAssets)
		{
			DropppedArray.Add(AssetData.GetAsset());
		}
	}
	// Asset being dragged from some external source
	else if (DragDropOperation->IsOfType<FExternalDragOperation>())
	{
		TArray<FAssetData> DroppedAssetData = AssetUtil::ExtractAssetDataFromDrag(DragDropOperation);
		if (DroppedAssetData.Num() < 1)
		{
			return DropppedArray;
		}
		for (FAssetData DroppedAsset : DroppedAssetData)
		{
			bOutRecognizedEvent = true;
			DropppedArray.Add(DroppedAsset.GetAsset());
		}
	}
	// Actor being dragged?
	else if (DragDropOperation->IsOfType<FActorDragDropOp>())
	{
		bOutRecognizedEvent = true;
		TSharedPtr<FActorDragDropOp> ActorDragDrop = StaticCastSharedPtr<FActorDragDropOp>(DragDropOperation);
		if (ActorDragDrop->Actors.Num() < 1)
		{
			return DropppedArray;
		}
		for (TWeakObjectPtr<AActor> ActorDD : ActorDragDrop->Actors)
		{
			DropppedArray.Add(ActorDD.Get());
		}
	}

	return DropppedArray;
}

#undef LOCTEXT_NAMESPACE
```
