Regaining focus of menu with controller/ keyboard

Godot Version

v4.2.stable.official [46dc27791]

Question

How would I go about checking and seeing if none of the elements in a VBoxContainer for example have focus, making the next keypress make the first element in the container have focus?

In my menus, I make the first element have focus on entry and can move around the menu with a controller. However, if I use a mouse to click outside of the menu, all elements lose focus and I can’t use a keyboard or controller to regain focus, so I would like to be able to fix this.

Thank you.

Check the Viewport gui_focus_changed signal.

You can use this to find which node has gained focus and if it’s one that you currently don’t want to have focus, change it back to a different one with grab_focus()

It just sounds like the mouse filter Stop can help here. For the mouse.
For everything else, it’s supposed to be Focus Mode all.
jodot19
The input shortcut is very confusing. You have to assign a Node. This means this is probable for multiple BoxContainers. Just in case. V and H. Vertical and Horizontal. It’s supposed to be assigned with another control node. That will have a replacement for your entry solution.

I don’t understand what you want. Either you’re a programmer. Or, you’re a scammer. Before user interface. The basic empty content folder was made as the terminal link. So a programmer could add a directory up command. Which one are you?

Right, I’m trying to figure out when NO elements have focus in a menu how to get a button press to regain focus of the first one

I tried out some of these options, but I couldnt get it to work. Clicking with the mouse outside of the menu makes it so none of the elements have focus, and I have to bring the mouse back again to regain focus, rather than use a controller

I’m sorry I dont understand what this means? Frankly, I’m not great at either one, which is why I’m here

Maybe this gif will help? When I open up the menu, I can scroll up and down with a controller, but when I click out of it with a mouse, I can’t use the controller on the menu anymore. How do I fix this?

controllerrefocusingissues

Looking at this, some other control node gains focus when you click on it.
That’s why I suggested using the signal so you can figure out which node that is. You can then change the focus mode on that node so it won’t get focus when you click on it, preventing this issue.

Be aware that any panel can potentially gain focus.

That worked! Thank you. Turns out the SubViewportContainer that everything was under was getting focus. I did not know that it could even be the culprit. Thanks Again.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.