godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.47k stars 21.07k forks source link

Focus does not work properly when the screen size changes when font oversampling is enabled due to font metrics changing #62878

Open AheadGameStudio opened 2 years ago

AheadGameStudio commented 2 years ago

Godot version

3.4.4 stable, 3.5 rc5

System information

Windows10 GLES3 NVIDIA GeForce GTX 1660 SUPER

Issue description

If you change the window to a different screen size than the project settings while it is running, focus will not work properly. I know the cause of it, but I don't know the solution.

I guess to conflict the font and the property. Attached small project so please check that.

Screen Resolution : 2560x1440 Window/HiDPI : ON

https://user-images.githubusercontent.com/186786/178140959-fa8aeaaf-a6a2-4821-9acb-968ce8c54cf0.mp4

Steps to reproduce

run it same composition as attached small project

Minimal reproduction project

FocusTest_3.5rc5.zip

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/56399.

This is likely because UI elements are slightly overlapping after you resize the window (due to font oversampling changing controls' sizes slightly), and the focus previous/next detector is confused by this.

Can you reproduce this after disabling font oversampling in the Project Settings? Another way to work around this is to manually define Focus Prev/Next neighbors in the control nodes in the inspector.

AheadGameStudio commented 2 years ago

@Calinou I disabled font oversampling in the Project Settings. Not reproduce. it's solved. thank you. 😊

Calinou commented 10 months ago

I can reproduce this on 3.5.3.stable, but not on 4.3.dev 13a0d6e9b (both on Linux).

Note that you may need to resize the window multiple times to be able to reproduce this. When the issue occurs, focus using arrow keys will jump over one of the items as if it didn't exist.