How do you make it so that when you click away from a control it loses focus? so for example i have my button selected, but I want it so that whenever you click in any other part of the screen it loses focus.
Thermodynamics it works for gaining focus, but to for releasing it. If i click on an empty part of the screen focus isn't lost
Maybe only Controls respond to clicking? Does the screen have a background that's a Control, like a ColorRect or TextureRect?
release_focus() ?
https://mcmap.net/q/2034/godot-how-to-remove-focus-from-control-nodes
Monnet
Create another Control node, which I will call "Background Control" for simplicity. On top of this node, add the Control node you're interested in; let's call "Main Control". Write code so that when the "Background Control" is clicked, it gains focus. This way, the focus is switched from "Main Control" to "Background Control". Tree structure could be this:
-Parent
--------Background Control
------- Main Control
OR this:
-Parent
--------Background Control
---------------Main Control
Attire Wow! Super good way of fixing this! Though there is a problem which is that when you focus on the background Control, it becomes outlined. To fix this I just set "Control > Theme Overrides > Styles > Focus" to a new StyleBoxEmpty. Leaving this here for anyone that this might help.
© 2022 - 2024 — McMap. All rights reserved.