Download

[Slate] SCanvas inside SScrollBox?

I am at a total loss when it comes to using SCanvas properly.

I am using an SScrollBox widget in order to display some data I have.
My original idea was to simply use a list of SButtons inside of SScrollBox, but it led to the problem of buttons not having an adjustable height (which is why I wanted to use SCanvas).
Now, I did test out my idea inside UMG Editor and I can in fact create an SScrollBox with SCanvas children. It lets me change the size of the buttons easily and behaves exactly as I want.

The problem occurs when I try to do this in code:



for (int i = 0; i < 10; ++i) {
    widget_ScrollBox->AddSlot().HAlign(HAlign_Fill).VAlign(VAlign_Fill)
    
        SNew(SCanvas) + SCanvas::Slot().Size(FVector2D(500, 75).Position(FVector2D(10, 10))
        
            SNew(SButton)
        ]
    ];
}


The following code works, however I cannot change the height of the buttons:



for (int i = 0; i < 10; ++i) {
    widget_ScrollBox->AddSlot().HAlign(HAlign_Fill).VAlign(VAlign_Fill)
    
        SNew(SButton)
    ];
}


I tried using this exact same code in an SOverlay and it works just fine, I can see the buttons (though they are of course stacked).
But with the SScrollBox I see nothing at all - I tried adjusting the position and size but I still don’t see any buttons.
Another variation I tested was using SVerticalBox -> SCanvas -> SButton thinking it might have to do with SCanvas being a direct child of SScrollBox but it also does not work :frowning:

Anyone out there using Slate and mind telling me what I’m doing wrong?

###Edit:
Managed to solve my issue by changing SCanvas into an SBox instead. Not really a “solution” per se, but it helps me achieve what I wanted to do.
SBox lets me specify the minimum width/height of the contained child widgets so user-defined sizing is in the picture here. Still would prefer to use SCanvas as it supports absolute positioning on the screen which is precisely what I need.
Hoping that maybe eventually I will figure out a solution - starting to think that maybe my code is stupid or I don’t fully understand underlying functionality.

Tried to delete the thread but that apparently doesn’t work, guess I’ll mark this as solved now?