Replies: 1 comment 6 replies
-
I don't consider this cumbersome at all. Because you will be applying a script to any control with behavior already. Or, will be using custom types already. (Adding SFX to buttons, etc.) You can also, do this globally, by subscribing to SceneTree.node_added and subscribing to the gui_input of ALL relevant control nodes. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As games often require UIs capable of quickly adapting between cursor and keyboard/controller inputs, many games, such as Elden Ring or Sea of Thieves, have implemented the "focus follows cursor" UX pattern, that enables UI elements to grab focus simply by hovering over them with the cursor. This allows for cleaner and simpler UIs, by removing the need of using two different "hover" and "focus" states, and also allows cursor and keyboard/controller input to be switched seamlessly.
As of now, Godot requires creating a custom script that extends control nodes to implement this feature properly, but it would require setting the same script for many nodes. Implementing it as an optional feature that can be controlled through a property of Control nodes would be a lot more straightforward. For example, each Control node could have a boolean property called "focus_on_hover" set to false by default. Or, it could have an Enum with three states:
Disabled - Focus does not follow the cursor
MouseEntered - Focus is grabbed only if the cursor enters the control
MouseHoveringAndMoved - Focus is grabbed any time the cursor is on a control and it is moved (This is the default behaviour as far as I'm aware)
Solving this with a plugin is possible, but as I've already said, it requires assigning the script to every control that requires it, which can become a bit cumbersome.
EDIT: Replies below have reminded me that I should also mention that implementing this feature with a script can become a bit tricky, since a focused and hovered on control will display its hover style, instead of the focus one. A proper implementation requires the focus style displayed even when the control is being hovered on.
Beta Was this translation helpful? Give feedback.
All reactions