Keep focus position when when turning visibility back on

Is there a way to keep the last focused control node still focused after turning the visibility of the parent on and off?

I’m making menus by turning the visibilities on and off, but the focus position always get’s reset to the default.

This behavior is hard coded in the engine. When a Control node is turned invisible, it automatically loses its focus.
You might be able to work around this by

Please note, that I haven’t tested this - it is just an idea. I’m not sure what you mean by “focus position”.

Also instead of creating a menu yourself, have you had a look at MenuBar?

1 Like

By focus position I meant which button/label/etc. was focused.

I know of the solution you proposed, but my problem with it is that you need reference to every menu item and connect a lot of signals. This means that for every new menu you make or change to an existing menu you have a lot of boilerplate work to do. This could also lead to a lot of errors.

I haven’t looked at the menubar yet, but I will give it a go, albeit from what I’m reading it uses popup menus rather than just any control node.

If there is no way to actually bypass this functionality I guess I will write a menu via gdscript, rather than using the inspector - this way I can safely change the number of items without breaking the focus.