iOS slate drag and drop

Does anyone have a working example of using drag and drop in Slate on iOS? I have it working fine in the mobile preview, but there is something that is causing it to assert and hang when I actually launch it on my iPad.

I started this just before UMG came out and I’m a little more comfortable with code anyhow, so I haven’t tried converting it to UMG yet (plus there is a lot more logic that I’d rather not have to implement in Blueprints if I don’t have to)

Here’s the code I’m using now:

FReply SDraggableIcon::OnTouchStarted( const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent )
{
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Touch Started!"));
    
    const TSharedRef<SWidget> DetectDragInMe = SharedThis(this);
    return FReply::Handled().DetectDrag( DetectDragInMe,EKeys::TouchKeys[0]);
}

FReply SDraggableIcon::OnDragDetected( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Drag Detected!"));
    TSharedRef<FNodeDragDrop> DragPayload( new FNodeDragDrop(NodeType, nullptr, IconImage));
    
    return FReply::Handled().BeginDragDrop(DragPayload);
}

On the iPad it displays the “Touch Started!” message but never the “Drag Detected!” message, so it must be getting hung up somewhere in the DetectDrag function. I also get this message in the debug output when I run it in debug mode from XCode:

Assertion failed: IsValid() [File:/Users/build/BuildFarm/build_++depot+UE4-Releases+4.5/Engine/Source/Runtime/Core/Public/Templates/SharedPointer.h] [Line: 658]

But I can’t set breakpoints (I just asked a different question on that one if anyone has ideas) to determine exactly what variable is causing the assert on IsValid()

So I’m stuck and any ideas or examples you can refer me to would be much appreciated!

Unfortunately, Drag Detection has not been thoroughly tested on mobile devices. You can detect a drag yourself by capturing the pointer and seeing how far the pointer (in this case a finger) has moved. If it moves more than a certain distance, you can trigger a drag/drop. However, DragDrop is also a concept thoroughly tested on PC but not on mobile devices. Often times, mobile interactions are simpler than those on PC, so your scenario may well be served by a custom DragDrop solution built by you. We hope these systems will improve to support mobile devices better; however this is their state right now.

Good to know Nick, I’ll look into implementing my own Drag and Drop code. thanks.