store focused widget to come back later

I need to add a pop-up widget in the game that when is enabled the UI focus is in the pop-up, but when the pop-up widget goes away then the focus goes back to the previous focused widget again.

I would like to avoid storing EVERY widget that is in focus in the game manually to get it back later.

Any workaround?
Dany

I found an easy workaround.

I have a main enhanced input mapping context for the game.
The trick is creating a second mapping context (popup-context?)
and when the widget pops up then I swap the enhanced input context
and then when is destructed I swap again: