Hey everyone,
I have a question related to UMG. I have a UUserWidget and I am trying to get the next UUserWidget that contains it. My initial intention was to use UWidget::GetParent() function, however I realized that for every widget whose parent is UUserWidget the UWidget::GetParent() returns null.
The reason for that is the fact that UWidget::GetParent() expects to have a UPanelWidget slot as its parent and UUserWidget is not a UPanelWidget and it doesn’t have a slot. Instead it seems to be keeping all its content inside a UWidgetTree.
Is there a workaround for that?
Here’s the code I was trying to use which doesn’t work. Posting it here just to help to illustrate the idea:
const FBuxWidgetContextData* UBuxUserWidget::GetWidgetContextData() const
{
FBuxWidgetContextData* Result = nullptr;
UWidget* Parent = GetParent();
while (Parent)
{
UBuxContextWidget* ContextWidget = Cast<UBuxContextWidget>(Parent);
if (ContextWidget)
{
Result = &ContextWidget->Context;
break;
}
Parent = Parent->GetParent();
}
if (!Result)
{
UE_LOG(LogBuxWidgets, Warning, TEXT("Missing context for %s"), *GetPathName());
}
return Result;
}
[USER=“2522”]Nick Darnell[/USER] ?
Thanks,
Robert.