Common Activatable Widget Stack very inconsistent behavior

When using the common activatable widget stack in common UI, I am getting problems when pushing and removing activatable widgets from the stack. Particularly, I am trying to push a pause menu to the screen.

It seems like when removing or deactivating widgets, they don’t actually fully reset and keep some properties which mess with how the UI works.

The first time I push the activatable widget to the stack, everything works as expected. However if I remove it, and add it again, multiple things break. For example, the first time the menu is pushed, it automatically switches to UI input mode and shows the cursor. The second time this doesn’t happen.

Also, in my pause menu, I have a common activatable widget switcher, and a corresponding common tab list to hold the tab buttons. When pushing the menu for the second time, the buttons that were previously there show up again, in addition to a new set of identical buttons (the old ones don’t work).

My master widget containing the widget stack looks like this:

And here is the pause menu (called context menu in this case):


I have also tried using Construct instead of On Activated, with the same results.
I have verified that the Destruct event is called when removing the pause menu widget.

Here is my hierarchy in the pause menu:

Here is a demonstration:

Any help is appreciated.

Update: Using OnInitialized removes the duplicate button problem. However it introduces a new problem; When pushing the pause menu for the second time, the tab buttons glitch out, they stick to the pressed state and don’t respond to presses.

Hi, from the BP_AddWidget() docs:

Note that all widgets added to the container are pooled, so the caller should not try to cache and re-use the created widget.

It is possible for multiple instances of the same class to be added to the container at once, so any instance created in the past is not guaranteed to be the one returned this time.

So in practice, you should not trust that any prior state has been retained on the returned widget, and establish all appropriate properties every time.

So each time you add the widget to the stack, it will be either a new instance or an already existing one, so you should clean and refresh its state in the “OnActivated” method.

For example, before initializing a list of widgets, make sure to clear the list first because you can’t assume its current state:

2 Likes