Cannot set background color to border in code

I have tried many times as possible as I can.
I wrote below code. Original is below link`s code.

	ChildSlot
		.VAlign(VAlign_Fill)
		.HAlign(HAlign_Fill)
		.Padding(FMargin(20))
		[
			SNew(SOverlay)
			+ SOverlay::Slot()
			.VAlign(VAlign_Bottom)
			.HAlign(HAlign_Right)
			.Padding(FMargin(20))
			[
				SNew(SBorder)
				.VAlign(VAlign_Center)
				.HAlign(HAlign_Center)
				.BorderBackgroundColor(FLinearColor(0, 1, 0, 1))
				.BorderImage(&brush)				
				.Padding(FMargin(20))
				[
					// Inside lies a text block with these settings
					SNew(STextBlock)
					.ShadowColorAndOpacity(FLinearColor::Black)
					.ColorAndOpacity(FLinearColor::Blue)
					.ShadowOffset(FIntPoint(-1, 1))
					.Font(FSlateFontInfo("Veranda", 16))
					// localized text to be translated with a generic name HelloSlateText
					.Text(LOCTEXT("HelloSlateText", "Hello, Slate!"))
				]
			]
		];

And result is this.

253043-result1.png

Yes. There is no background color just transparent.

When I edited like this…

    				SNew(SBorder)
    				.VAlign(VAlign_Center)
    				.HAlign(HAlign_Center)
    				.BorderBackgroundColor(FLinearColor(0, 1, 0, 1))
    				//.BorderImage(&brush)				
    				.Padding(FMargin(20))

And result is…

253046-rerult2.png

See. Only border line has color. It`s not that I want. I want to fill color like working in UMG.

How can I fill color to background? Need any other option or something?

(I wrote this project at 4.20.2)

I solved it. Check below link.

Declare FSlateBrush at header, not .cpp source file. And if you use it to fill background, color will apply with no problem

.h

//....
FSlateColorBrush brush = FSlateColorBrush(FLinearColor::Yellow);
//....

.cpp

SNew(SBorder)
    .VAlign(VAlign_Center)
    .HAlign(HAlign_Center)
    .BorderImage(&brush)  
//...

Result

253141-answer.png

Hope this helps who is trying to use slate in code.

2 Likes