Download

Button state images will change at initialisation but not after widget is displayed

I have setup a widget that has three buttons. The images for the various button states are set using the OnInitialized event. This all works as expected.

I want it so that when the player clicks on one of the buttons, the state images get changed to show which button was last clicked/selected.

I have set up the OnClicked event for the buttons to change the images as required. I can see that the OnClicked events are firing however the image changes are not taking place.

I am using the same method to change the images as I am with the OnInitialize event so there is no difference.

Can anyone think of any reason this would happen?

In order to change the Button style, you’ll have to take the outputs of your new Slate Brush nodes, then use them to create a “Button Style” struct, and then finally use the struct to “Set the Button Style”. Basically the reverse process of accessing button style information.

I have tried this and unfortunately still get the same issue.

I added some text boxes to show the updated image names for debug purposes. The images are being updated as expected but they are not actually being displayed for some reason. Is there something I ave to do to refresh the UI?

https://i.ibb.co/8bjGmfs/UITest.png

There should be no need to refresh the UI. Could you share a screenshot of how you are setting the images during initialization?

I am essentially calling the same event from OnInitialized and it works fine.

It just doesn’t seem to work if called again after the widget is already displayed.

Can anyone help with this?

Should I be creating the buttons as their own widgets?

Everything look alright there. What happens if you dont set the Active Icon during initialization? Does it repeat the same behavior of setting images only during the first click and not after that?

I have just tried this and I am left even more puzzled.

Without the Icons being set during initialization, the button uses the default background image for all states.

Each time I test and click the first weapon button, I get different results for the button images. Firstly the button I am clicking doesn’t get updated at all. The other two sometimes have their hover image updated and other times their hover image doesn’t change but their pressed image does.

The same code is being fired every time I press button 1 however the outcome changes…

Ok so I can’t get to the bottom of this as it seems to be some sort of bug with the buttons.

I have come up with a work around consisting of using images for the actual normal and pressed/selected state. I then have a button on top that uses and empty texture.

On the button press I then change the images rather that the button style.

This actually ended up being a lot less effort to change the images but does lose some of the visual effects of the button.

Same problem, anyone found a solution to this yet?