godotengine / godot

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

Setting button to pass mouse events makes clicking difficult on Android #95532

Open j-zeppenfeld opened 3 months ago

j-zeppenfeld commented 3 months ago

Tested versions

System information

Android, Samsung Galaxy S10e

Issue description

In order to make menus touch scrollable in Android, buttons must be set to pass mouse events. In Godot 4.2, the dead zone before the button passed motion events was big enough to allow consistent pressing of the button. In Godot 4.3, this dead zone seems to be practically 0, making clicking the button all but impossible.

Steps to reproduce

Create a simple UI with a ScrollContainer, VBoxContainer and enough Buttons to get the ScrollContainer to scroll. Set the buttons to pass mouse events (in order to make the ScrollContainer touch scrollable). Run the project on Android. While scrolling works, clicking the buttons is practically impossible.

Minimal reproduction project (MRP)

The top three buttons are set to pass mouse events and work to scroll, but are difficult to click. The bottom three buttons are set to stop mouse events and cannot be used to scroll, but can be easily clicked. In Godot 4.2, both scrolling and clicking are easily possible on the top three buttons.

exittest.zip

akien-mga commented 3 months ago

May be related to https://github.com/godotengine/godot/issues/93612, cc @m4gr3d @Alex2782

Alex2782 commented 3 months ago

this dead zone seems to be practically 0

yes for #84138 and #84182. However, it is possible to customize Scroll Deadzone in the ScrollContainer.

image


In the next few days I will try to create PR for new default value, first I would have to check the effects on other operating systems.

https://github.com/search?q=repo%3Agodotengine%2Fgodot+scroll_deadzone&type=code

j-zeppenfeld commented 3 months ago

This is an interesting conflict of interest, with touch responsiveness on one side and ui usability on the other.

Manually setting the scroll dead zone of all scroll containers works fine for my project.

I would recommend adding this to known issues for the 4.3 release. I imagine there will be quite a few Android projects with unusable UI because of this change.

Alex2782 commented 3 months ago

scroll_test.zip

@j-zeppenfeld : I couldn't find any issues with deadzone = 0 on my Android devices. See video, from which deadzone value is everything ok on your device? (DPI / Scale / Size values?)

Perhaps we can somehow take the DPI / Scale / Size values into account for touchscreens.

Video: Samsung Tab S7, 12.4" display https://github.com/user-attachments/assets/17922bf5-f198-4de6-b0a9-fc9c9fffa840

Also on my Pixel 4a, 5.8" display, DPI: 440, Scale: 1, Size: (2340, 1080) like in video 100% no scroll events triggered.


Note: There is a bug, already 6 years old. Further down in the ScrollContainer scrolling over controls does not always work, pressed should always work there 😃

Video: issue #22936 https://github.com/user-attachments/assets/8d811734-7ea8-442e-be5c-2d17a1a9712c
j-zeppenfeld commented 3 months ago

Deadzone=0 is definitely not usable on my Galaxy S10e (DPI 480 Scale 1 Size 2280x1080), quick taps from an experienced user are ok at deadzone=2, for less experienced users I would probably set the deadzone to at least 4, probably higher.

Here's a video of what it looks like on my device:

https://github.com/user-attachments/assets/fd081112-b0e5-45ab-bd14-ff6a80c112c8

j-zeppenfeld commented 3 months ago

Playing with this some more, it seems that my device is especially eager to send InputEventScreenDrag.

The absolute minimum output I can achieve for as short a tap as possible always includes at least 5 events: an InputEventScreenDrag surrounded by press and release InputEventMouseButton and InputEventScreenTouch events.

Alex2782 commented 3 months ago

@j-zeppenfeld If you find time please try PR #95827, with your productive projects.

or android_debug_base_button.apk 27 MB Download https://drive.google.com/file/d/1vVCK1tUHzi6kloKjcY698CBDkDDrGv9q/view?usp=sharing

Bildschirmfoto 2024-08-20 um 23 08 10


adb logcat -s godot

Logs: on my Samsung Tab S7, pressed_tolerance = round (DPI / 50)

08-20 22:52:53.344 16666 16735 I godot   : InputEventMouseMotion, drag_from:  (846.6693, 378.7633) , is_scrolling:  true
08-20 22:52:53.344 16666 16735 I godot   :   drag_from:  (846.6693, 378.7633)
08-20 22:52:53.344 16666 16735 I godot   :   get_mouse_position:  (844.67, 380.762)
08-20 22:52:53.344 16666 16735 I godot   :   diff:  (-1.999207, 1.998657)
08-20 22:52:53.344 16666 16735 I godot   :   pressed_tolerance:  7
j-zeppenfeld commented 3 months ago

@j-zeppenfeld If you find time please try PR #95827, with your productive projects.

Yup, working great in both projects (my main pixel art project and your modified exit test project). Thank you!