Hi,
I am trying to move a widget which is in a SCanvas Slot. SCanvas allow me to place a widget wherever i want which is nice. Now i want to move that widget around, the mouse position values are changing but the widget is not moving.
here is a small part of my code :
SCanvas::FSlot s = Canvas->AddSlot()
.Position(FVector2D(item->Position.X*slotSize, item->Position.Y * slotSize))
.Size(FVector2D(item->Size.X * slotSize, item->Size.Y * slotSize))
SNew(SDE_InventorySlotWidget)
.OnDragDetectedDel(this, &SDE_InventoryUIWidget::OnDragItem, index)
.OnMouseMoveDel(this, &SDE_InventoryUIWidget::OnMoveItem, index)
.OwnerHUD(OwnerHUD)
.Item(item)
.Parent(s)
];
void SDE_InventoryUIWidget::OnMoveItem(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, SDE_InventorySlotWidget* widget, int32 index)
{
positionList[index] = FVector2D(MouseEvent.GetScreenSpacePosition().X, MouseEvent.GetScreenSpacePosition().Y);
widget->Parent.Position(positionList[index]);
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("OnMoveItem at : %s"), *widget->Parent.PositionAttr.Get().ToString()));
}
}
In another class i got widget moving but with an SOverlay and using “Parent.Padding(FMargin(posX, posY, 0, 0));” , i would prefer use SCanvas this time as it seems to be a better solution but i can’t get it to work, if someone has an idea let me know !
Thanks !