I want to move widgets around in the VerticalBox in-game, but it doesn’t offer that functionality that I know of, so I created my own class base on it. I tried programming the functionality, but it doesn’t seem to work:
//=================================================================
//
//=================================================================
void UVerticalDynamic::SwitchWidgets(UWidget* Content1, UWidget* Content2)
{
if (!MyVerticalBox.IsValid())
return;
UVerticalBoxSlot *pSlot1 = NULL;
UVerticalBoxSlot *pSlot2 = NULL;
for (UPanelSlot* Slot : Slots)
{
UVerticalBoxSlot* TypedSlot = Cast<UVerticalBoxSlot>(Slot);
if (!TypedSlot)
continue;
if (Slot->Content == Content1)
pSlot1 = TypedSlot;
if (Slot->Content == Content2)
pSlot2 = TypedSlot;
}
if (!pSlot1 || !pSlot2)
{
UE_LOG(LogTemp, Warning, TEXT("Could not find slots!"));
return;
}
UWidget *pTemp = pSlot2->Content;
pSlot2->Content = pSlot1->Content;
pSlot1->Content = pTemp;
RebuildWidget();
}
Anyone have any insight what I am doing wrong?