Hello,
Similar to this question Why do STreeView sub-nodes not expand? - UI - Unreal Engine Forums
My STreeView widget won’t expand when I click on a parent that’s below the root level.
My code
void SDialogTreeWidget::Construct(const FArguments& Args)
{
Items.Add(MakeShareable(new FString("String1")));
Items2.Add(MakeShareable(new FString("String6")));
Items2.Add(MakeShareable(new FString("String7")));
TreeViewWidget = SNew(STreeView<TSharedPtr<FString>>)
.ItemHeight(48)
.TreeItemsSource(&Items)
.OnGenerateRow(this, &SDialogTreeWidget::OnGenerateRowForList)
.OnGetChildren(this, &SDialogTreeWidget::GetChildren01);
ChildSlot
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
[
TreeViewWidget.ToSharedRef()
]
];
}
TSharedRef<ITableRow> SDialogTreeWidget::OnGenerateRowForList(TSharedPtr<FString> Item, const TSharedRef<STableViewBase>& OwnerTable)
{
return
SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
.Padding(2.0f)
[
SNew(STextBlock)
.Text(FText::FromString(*Item))
];
}
void SDialogTreeWidget::GetChildren01(TSharedPtr<FString> Item, TArray<TSharedPtr<FString>>& OutChildren)
{
if (*Item == "String1")
{
OutChildren.Add(MakeShareable(new FString("String2")));
OutChildren.Add(MakeShareable(new FString("String3")));
OutChildren.Add(MakeShareable(new FString("String4")));
OutChildren.Add(MakeShareable(new FString("String5")));
}
else if (*Item == "String3")
{
OutChildren.Append(Items2);
}
}
Widget looks like this. Clicking on the arrow or double clicking won’t expand String3