Hello! I’m having a problem with my buttons not reseting their animation state when switching to different widgets, as they get stuck in the ‘OnHovered’ animation state when a different widget is pushed. Is there any way to have the button animation reset its state or somehow clear it when a different widget is activated?
Many ways to solve it, depends on your interface architecture.
Since we don’t know how its setup, here is a list of high level solution space.
- When a sub menu is open and you switch, on main container there is and event OnWidgetStateChanged. You bind every widget onto this on construct and when changed they always reset animations.
- You can change your structure, think you are using widget switcher or show hide. You can just remove from parent container and add to container every sub widget. Thus they are reset when they come.
- On every sub widget you can bind to its local event on visibility changed, to reset animations. OnVisibilityChanged->GetAllChildren->ForEach->SetButtonState Unhovered.
If this is not helpfull please do define what is happening when you press a button and sub menu opens in detail.
Hey there, I appreciate the response. I think the video explains the issue a lot better, it isn’t only the animations but also setting the style of the text when hovered for instance. No one of it is widget switchers, it’s a CommonUI setup very similar to Lyra’s with UI layers. I can elaborate more if needed!
Attaching some more screenshots of the setup:
Here’s a code snipped that fixes the issue, however I was wondering if there isn’t a better way of going about it
Understood ok, I basically use a similar system where widgets are pushed to different ui layers and restored if there is a stack.
I have events for that when a widget pushed in as created or from stack and removed so I can do animations etc. procedurally.
However since you are using an activatable widget base you can
OnActivated
OnDeactivated
OnHandleBackAction (if you are using)
OnFocus(You can use if you check on the class auto restore focus)
OnVisibilityChanged (you can set this also to visible(activated) - collapsed(deactivated)
So the thing you did is very valid.
If you want to over engineer it. OnConstruct you can hold the button references so you don’t have cast again.
Alright, thanks a lot for the input!