Download

Slate: SComboBox RefreshOptions has effect?!

Hi folks,

I’m trying to use the SComboBox widget for my Slate UI. The thing I want to accomplish is having a combobox displaying a collection of name attributes of custom objects. A feature I would like to add is making the selected object, that is, it’s name editable. Therefore I\m using the SEditableText widget in the SCombeBox’s ]. The code looks something like this:



                SAssignNew(this->SessionSelection, SComboBox<TSessionComboboxItem>)
                .OptionsSource(&StatsTracer::TDRM->GetSessionArray())
                .InitiallySelectedItem(SelectedSessionItem)
                .OnGenerateWidget_Lambda(](TSessionComboboxItem InOption)
                {
                    return SNew(STextBlock).Text(FText::FromString(FString::Printf(TEXT("%s"), *InOption->GetAllias())));
                })
                .OnComboBoxOpening_Lambda(&]() 
                { 
                    this->SessionSelection->RefreshOptions();
                })
                
                    SNew(SEditableText)
                    .Text_Lambda(&]() 
                    { 
                        if (this->SelectedSessionItem.IsValid() == false)
                            return FText::FromString("No Session Available.");

                        return FText::FromString(this->SelectedSessionItem->GetAllias()); 
                    })
                    .OnTextChanged_Lambda([this](const FText& InFilterText) 
                    { 
                        if (this->SelectedSessionItem.IsValid() == false)
                            return;

                        this->SelectedSessionItem->SetAllias(InFilterText.ToString()); 
                    })
                ]


SelectedSessionItem is a TSharedPtr of a custom type, which contains a FString for holding an allias name. The above code works and actually changes the allias, but when opening the combobox to select another item the displayed options do not get updated. It seems that the OnGenerateWidget_Lambda function is only called once at the widget’s creation time. When I reoen the Panel/Window which contains the combobox all changed options will get displayed correctly.

So my question is: does someone know how to solve this problem? My best idea would be to recreate the whole widget, but I do not know how to do so.

Things I also tryed so far:

  • make the widget volatile and use Invalidate when opening combobox
  • try to use the ‘.Text_Lambda’ version in ‘OnGenerateWidget_Lambda’ (this will cause the editor to crash)

Thanks in advance.

Cheers,
Tobs.