Invisible UI elements grab focus

Godot Version

Godot 4.2.2.stable


I love the control nodes workflow. I love designing UIs in Godot, there’s just this one thing that’s been bugging me across multiple project and now I feel like there must be a way of doing this.

See this UI? The button “Minigun” has hover and focus, when pressing the arrow down, a UI element that’s visible but drawn underneath this UI layer get’s focused instead of a button below it.

I’ve always tackled this by crafting for-loops that assign strict focus neighbors, am I missing something? Is there a way make sure that elements not visible on screen at the moment don’t get selected? Does the z-index affect this at all?


I didn’t try it, but when hiding your UI element maybe also set its focus_mode to None and/or the mouse_filter to Ignore.

The thing is that I don’t want to hide, the element is ‘hidden’ because it is behind other elements, hence not visible on screen. It is visible in the scene tree but on on screen.

You probably need to ensure this is set correctly based on your intended behavior

Screenshot 2024-06-04 101048

Mouse filter is set correctly I’m certain, however I am talking about the focus that occurs as a result of arrow keys, not mouse (one element focused, arrows keys pressed in either direction, when the engine decides what the next item is depending on its position on screen)

Can you post a screenshot of your scene tree? :thinking: Most importantly: What are the parent (UI) nodes of the “Minigun” button, and where is the UI element that gets selected located relatively to it?