Change the Size of the scroll bar on a ComboBox

Well, I found a solution. Its not pretty but it works… keep in mind it requires a fair bit of setup in c++;

Comboboxes do support an option for a custom scrollbar:

MyComboBox = SNew(SComboBox<TSharedPtr<FString>>).CustomScrollbar(SScollbar)

So, what I did was this:

  1. Create a c++ UserWidget class that will handle building our custom ComboBox
  2. Create a c++ Widget class that creates a custom Scrollbar (since scrollbars arent available in blueprints)
  3. Add both the custom ComboBox, and the Custom Scrollbar to the same widget
  4. Tell our combobox to use the scrollbar we are providing
  5. Finally, we can arrange the combobox and scrollbar however we like so it will maintain a size that scales well

There is one final hack that was necessary to get this all working. When adding the custom scrollbar, there is an issue where any time you try and click on the scrollbar, the combobox loses focus and closes. To avoid this I tried to add the following to the menu open lamba for the combobox. This code makes it so when we open the combobox, it forces the combobox to reopen except without having the menu focused. This prevents the menu from closing when we select our custom scrollbar!

MyComboBox = SNew(SComboBox<TSharedPtr<FString>>)
.OnComboBoxOpening_Lambda([this, ComboBoxState]()
    {
        if (ComboBoxItems.Num() > 0)
        {

// When I open the menu start a ticker            
FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([this](float DeltaTime) {
                static int32 Step = 0;

                
                if (!MyComboBox.IsValid())
                {
                    return false; // Stop ticking if the combo box is invalid
                }
                // First wait for the combobox to open, then close it
                if (Step == 0)
                {
                    if (MyComboBox->IsOpen())
                    {
                        MyComboBox->SetIsOpen(false);
                        Step = 1;
                    }
                }
                // Then, reopen the combobox except this time tell it to unfocus on the menu
                else if (Step == 1)
                {
                    if (!MyComboBox->IsOpen())
                    {
                        MyComboBox->SetIsOpen(true, false, 0);
                        return false; // Done! Unregister ticker
                    }
                }

                return true; // Keep ticking
                }), 0.01f); // Tick every ~10ms
        }
         
    })