godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix `ColorPicker` virtual keyboard popup on mobile

Open syntaxerror247 opened this issue 1 year ago • 11 comments

This PR fixes auto popup of virtual keyboard when colorPickerButton is pressed on mobile devices. Fixes #88235

syntaxerror247 avatar Oct 04 '24 10:10 syntaxerror247

It looks good but I don't know if we should return from TextEdit and LineEdit show_virtual_keyboard instead, to avoid showing the virtual keyboard when a physical keyboard is detected, at least we can do it for android and ios only but what if the users still wants to use the virtual keyboard ? There's no option to prefer virtual keyboard over physical one.

WhalesState avatar Oct 04 '24 11:10 WhalesState

@WhalesState Isn't this the current behaviour, virtual keyboard does not appear if physical keyboard is connected.

syntaxerror247 avatar Oct 04 '24 12:10 syntaxerror247

@WhalesState Isn't this the current behaviour, virtual keyboard does not appear if physical keyboard is connected.

There was no way to check for physical keyboards before, it was recently merged so it always show the virtual keyboard on android and ios by default.

WhalesState avatar Oct 04 '24 12:10 WhalesState

That's why i have applied a hack for this, since focusing any LineEdit or TextEdit will still show the virtual keyboard even if a hardware keyboard is connected, but I don't know if there are any opened issues or discussions about this.

WhalesState avatar Oct 04 '24 12:10 WhalesState

There was no way to check for physical keyboards before, it was recently merged so it always show the virtual keyboard on android and ios by default.

No, virtual keyboard doesn't appear if physical kb is connected even before that PR . This was used internally just wasn't exposed.

syntaxerror247 avatar Oct 04 '24 12:10 syntaxerror247

There's an option on android Physical keyboard settings Show on-screen keyboard while a physical keyboard is being used, which is true by default.

WhalesState avatar Oct 04 '24 12:10 WhalesState

There's an option on android Physical keyboard settings Show on-screen keyboard while a physical keyboard is being used, which is true by default.

I just checked in two different devices and it was turned off in Motorola and turned on in Xiaomi, both are default. So, yeah the only way to fix this will be to not call show_virtual_keyboard() in lineEdit and textEdit.

But that is out of scope of this PR.

syntaxerror247 avatar Oct 04 '24 12:10 syntaxerror247

The linked issue was closed by another PR. Is this still relevant?

KoBeWi avatar Oct 05 '24 14:10 KoBeWi

The linked issue was closed by another PR. Is this still relevant?

Yes, this fix is simpler and IMO better. I think the only difference is that, fix in that PR hides virtual keyboard but still keep html_color box focused, But I think completely removing the focus would be better.

@KoBeWi It would be great if you could have a look at changes 🙂

syntaxerror247 avatar Oct 05 '24 14:10 syntaxerror247

I've approved this PR since it was submitted after my own fix and my PR was approved but not merged yet. However, I do have some questions about the approach taken here.

I'm not sure why this fix was submitted as a separate PR instead of being discussed in my original PR, where the issue was already being tracked and addressed.

Regarding the fix itself, I agree that it's simpler. However, I do have some concerns about its accuracy. Specifically, every popup should focus on at least one control.

Also to avoid potential regressions on other platforms when has_hardware_keyboard() is supported, I made sure to apply the changes only to Android and iOS.

I'm not familiar enough with the underlying mechanics to provide a definitive opinion on which fix is better. I'd be happy to let more experienced team members weigh in and provide guidance on the best approach.

WhalesState avatar Oct 05 '24 16:10 WhalesState

I'm not sure why this fix was submitted as a separate PR instead of being discussed in my original PR, where the issue was already being tracked and addressed.

That PR was already addressing multiple issues, so I thought it would be better to open a new one. ( I accept that was an error an my part)

Regarding the fix itself, I agree that it's simpler. However, I do have some concerns about its accuracy. Specifically, every popup should focus on at least one control.

If hardware keyboard is not connected, this fix won't even create a popup or automatically try to open virtual keyboard (when colorpicker button is pressed). It will only focus the html_color field if hardware keyboard is connected OR specifically clicked on the html_color field.

Also to avoid potential regressions on other platforms when has_hardware_keyboard() is supported, I made sure to apply the changes only to Android and iOS.

This fix won't affect any other platform because has_hardware_keyboard() will always return true on any other platform. And if this func gets supported on other platforms then it should work there too.

I hope all your questions are answered :)

syntaxerror247 avatar Oct 05 '24 17:10 syntaxerror247

Thanks!

Repiteo avatar Oct 21 '24 21:10 Repiteo