How do I assign a FslateBrush to an SImage object?

Heyas!

I’m trying to get to terms with Slate, but it’s being fairly uncooperative so far - though I feel I’ve gotten a fair way.

My current problem is that I have a Slate widget with a child SImage in it - depending on the state of this widget, I want the SImage to change the FSlateBrush it’s rendering.

Assigning the initial FSlateBrush is easy and it works perfectly, but if I want to change that FSlateBrush later I have no clue how I’d go about it… SImage doesn’t contain a SetBrush function or anything similar that looks like it could be used.

Any suggestions?

Hi ReqPro, normally what we do is just swap the brush we want to use. Using the attribute system you could just assign a delegate to return the needed brush for the SImage given the current state, instead of assigning a particular brush when you create it.

Cheers,
Nick (Epic Games)

You would use a delegate to do this.

Create a function on your widget which returns a const FSlateBrush* and then bind it to the SImage rather than passing the brush pointer directly.

This is how dynamic bindings are handled in Slate (for things that use SLATE_ATTRIBUTE).

eg) SNew(SImage).Image(this, &MyWidget::GetImageBrush)

Of course! Bindings! That makes perfect sense…
I’m now tempted to go bang my head against the wall repeatedly…

Thanks a million guys!