godot icon indicating copy to clipboard operation
godot copied to clipboard

Color Picker on Mobile causes keyboard to popup by default

Open Bimbam360 opened this issue 1 year ago • 7 comments

Tested versions

v4.3.dev2.official [352434668], likely has existed for longer.

System information

Pixel 6a Android

Issue description

When clicking on the color picker button it by default brings up the onscreen keyboard. Likely because the 'Hex' field is active by default.

Why is this a bug? See below: Screenshot_20240212-173731

Setting hex_visible to false does not work around the issue.

Steps to reproduce

Add a ColorPickerButton node. Click it.

Minimal reproduction project (MRP)

Am not near computer, but can MRP if required later.

Bimbam360 avatar Feb 12 '24 06:02 Bimbam360

This is because the HTML color field is autofocused when opening ColorPicker, and this causes a virtual keyboard to pop up.

Is there a way we can have an autofocusing field on Android/iOS without making a virtual keyboard pop up? This would be the ideal solution here, so it still works as expected when you have a hardware keyboard connected.

Calinou avatar Feb 12 '24 21:02 Calinou

Is there a way we can have an autofocusing field on Android/iOS without making a virtual keyboard pop up? This would be the ideal solution here, so it still works as expected when you have a hardware keyboard connected.

This may fix the issue https://github.com/godotengine/godot/pull/87674, we can use grab_focus() instead of grab_focus_edit() on mobile.

WhalesState avatar Feb 13 '24 18:02 WhalesState

This may fix the issue https://github.com/godotengine/godot/pull/87674, we can use grab_focus() instead of grab_focus_edit() on mobile.

I don't see grab_focus_edit anywhere in the Godot codebase in master. Is that a method added by a PR?

Calinou avatar Oct 02 '24 13:10 Calinou

I don't see grab_focus_edit anywhere in the Godot codebase in master. Is that a method added by a PR?

It was changed for compatibility.

the only way now to grab_focus() without editing is to use the arrow keys when focusing the LineEdit, so maybe we can send an input action event ui_up before using grab_focus() to prevent it from entering edit mode on android, or we don't focus the hex_edit on mobile devices.

Edit: The ColorPicker Window will become hidden when Enter is pressed, so the LineEdit will have to accept the ui_text_enter and ui_cancel events to prevent hiding the popup when editing is toggled. But this is not enough, we will still be unable to trigger any button with ui_accept, maybe it's better to only hide the window when ui_cancel is pressed.

WhalesState avatar Oct 02 '24 13:10 WhalesState

The linked pull request will disable editing before focusing the hex LineEdit and will enables it again as a hack to only focus without editing on android and ios.

WhalesState avatar Oct 02 '24 15:10 WhalesState

@WhalesState I think using has_hardware_keyboard method will be better for this issue. As @Calinou mentioned, this method will ensure that its Usability will remain unchanged with hardware keyboard on mobile devices.

syntaxerror247 avatar Oct 04 '24 09:10 syntaxerror247

@WhalesState I think using has_hardware_keyboard method will be better for this issue. As @Calinou mentioned, this method wil ensure that its Usability will remain unchanged with hardware keyboard on mobile devices.

Yes, I will check for hardware keyboard on ios and android devices only, since it may cause issues on some other platforms.

Yet the hack will be needed to avoid showing the virtual keyboard when the ColorPicker popups and no hardware device is connected, since this is the original issue.

If we use this to return from (LineEdit/TextEdit) show_virtual_keyboard when DisplayServer::get_singleton()->has_hardware_keyboard() is true, it will never show the virtual keyboard on Web (android/ios) since it will always return true on Web.

WhalesState avatar Oct 04 '24 10:10 WhalesState