Widget interaction and button hover state

Hi,
I’m trying to get my pause menu with button to work with widget interaction, but I’m having problems with buttons and their hover states. My widget is a simple 3d widget component which has its visibility toggled when pausing/unpausing. This causes a problem if a button is in a hovered state when the component gets hidden - the state persists after the component is shown again. Only when I point at the button and move away, the state gets reset to normal. Can I somehow force buttons to update their state to normal after making them visible?

Hey there @Pete_the_B! So the button state system isn’t really exposed so you’d have to make code changes to the buttons states directly. It’s a workaround but might be easier if the unpause event plays to then change the button’s style. As long as you aren’t use gamepads and require correct feedback with the focused system it shouldn’t be a problem.

Thanks - I’ve tried implementing this workaround, but unfortunately, I’ve run into more problems. Currently, I’m trying to set normal style for hovered state when the button is pressed and the game unpaused, and revert the hover style on first hover:

This has one problem - the hovered style is not set when the widget is shown again and the button gets pointed at, because it still thinks it’s in hovered state, so the On Hover event doesn’t fire. I have to point away from the button and back again to let it trigger.

Hrm, so OnHover doesn’t fire again, but does On Mouse Enter fire? If so you could use that to set the style back to normal.
image

I was trying to dig up a project where I did something similar but I can’t remember which it was!

A complete shot in the dark - have you tried disabling and re-enabling the button in addition to the visibility change - perhaps that would reset its state?

image

Unfortunately, it doesn’t help.

This creates another issue - whenever I point at the widget, but not at the button, the on mouse enter event fires and the button shows the hovered style again, since it still thinks it’s hovered over. I would need to somehow reset that state, so we’re back at the original problem. Unless there’s a way to handle mouse enter only for this button.

Hrm, so I guess our options are to edit the Slate script where the state system is or do something a bit more hacky. The final shot, is does the button call unhover if you change the position of the button?

No - changing position or invalidating the widget doesn’t help. Looks like it wants to wait for the mouse to leave anyway.

Sorry about that! I’m going to have to do a bit of research on the state system to recommend how you can modify it directly.

I am having this same issue, did you ever find a workaround? the “is hovered” function will not update its state after an on drop event, only once the mouse is hovered again will it update.

Unfortunately no. Haven’t checked 5.1 yet, but in 5.0 there doesn’t seem to be a workaround.

Hello !
Well, I got exactly the same issue.
Tried a couple of stuff (volatile, find the widget path, redraw etc …).
Couldn’t find a solution.

Anyone has an update on this ?

Thanks in advance

Hello, I ran into the same issue and was able to find a workaround using a hack. I set the widget interaction distance to 0 with a small delay to remove the hover state from the menu before hiding it.

Then I reset the interaction distance when bringing up the pause menu. It’s pretty ugly, but it’s the only solution I’ve found that works.

3 Likes