Download

local coords as offset when dragging widget

im using widget local coords as offset in viewport when im dragging widgets, but its not working by some reason.

// at widget


FReply UInventoryWidget::NativeOnMouseButtonDown(const FGeometry & InGeometry, const FPointerEvent & InMouseEvent)
{
    controller->PanelDrag(this, this->GetCachedGeometry().AbsoluteToLocal(InMouseEvent.GetScreenSpacePosition()));
    return FReply::Handled();
}

// controller vars



    UUserWidget* DraggingPanel;
    FVector2D DraggingPanelOffset;
    void PanelDrag(UUserWidget* panel, FVector2D offset) { DraggingPanel = panel; DraggingPanelOffset = offset; }


// at controller frame tick




void AController::Tick(float DeltaTime)
{
    if (DraggingPanel)
    {
        MoveDraggingPanel();
    }
}

void AController::MoveDraggingPanel()
{
    FVector2D mouseposition;
    GetMousePosition(mouseposition.X, mouseposition.Y);
    DraggingPanel->SetPositionInViewport(mouseposition - DraggingPanelOffset);
}

https://www.youtube.com/watch?v=4541mHMFbdc

no ideas guys?

Any ideas guys?

Any ideas guys?

=( i dont get it