[Slate] STreeView selected image showing as black

Like it says, I have an STreeView in Slate that uses a custom widget with images for the items, when I select the item, however, the images turn black, like this:

2562-treeviewselected.jpg

Is there something I need to change somewhere to stop it happening? I had a look at the source code but I’m still getting to grips with finding/understanding stuff in there.

(Also, having Slate work in the editor is awesome, makes testing stuff that little bit easier :slight_smile: )

Hi Ineni, can you post or pastebin the code used to generate this widget? Thanks!

Unfortunately the code’s a bit scattered over about 2000 lines, but I found the solution, so I’ll post it as an answer :slight_smile:

So the solution turned out to be creating an FTableRowStyle and applying it from the style sheet, like this:

FSlateColor InvertedForeground =  FLinearColor( 0, 0, 0 );
	FSlateColor SelectorColor =  FLinearColor( 0.4f, 0.4f, 0.4f );
	FSlateColor SelectionColor =  FLinearColor(0.4f, 0.4f, 0.4f );
	FSlateColor SelectionColor_Inactive =  FLinearColor( 0.25f, 0.25f, 0.25f );
	FSlateColor SelectionColor_Pressed =  FLinearColor( 0.f, 0.f, 1.f );


   FTableRowStyle NormalTableRowStyle = FTableRowStyle()
    		.SetEvenRowBackgroundBrush( FSlateNoResource() )
    		.SetEvenRowBackgroundHoveredBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, FLinearColor(1.0f, 1.0f, 1.0f, 0.1f) ) )
    		.SetOddRowBackgroundBrush( FSlateNoResource() )
    		.SetOddRowBackgroundHoveredBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, FLinearColor(1.0f, 1.0f, 1.0f, 0.1f) ) )
    		.SetSelectorFocusedBrush( IMAGE_BRUSH( "Common/Selector", Icon8x8, SelectorColor ) )
    		.SetActiveBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, SelectionColor ) )
    		.SetActiveHoveredBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, SelectionColor ) )
    		.SetInactiveBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, SelectionColor_Inactive ) )
    		.SetInactiveHoveredBrush( IMAGE_BRUSH( "Common/Selection", Icon8x8, SelectionColor_Inactive ) )
    		//.SetTextColor( DefaultForeground )
    		.SetSelectedTextColor( FLinearColor( 0.72f, 0.72f, 0.72f, 1.f ) );
    
    	Style.Set( "MyGame.RowStyle", FTableRowStyle( NormalTableRowStyle) );

(I think the important one’s .SetSelectedTextColor, but I can’t quite remember…)

Then using it as the base-style in my custom widget’s construct function, like this:

STableRow<TSharedPtr<FString>>::FArguments rowArguments = STableRow<TSharedPtr<FString>>::FArguments().Style(FEditorStyle::Get(),"MyGame.RowStyle");

STableRow< TSharedPtr<FString> >::ConstructInternal(rowArguments, InOwnerTableView );