Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text_changed signal for LineEdit Node is improperly emitted multiple times on mobile (iOS) #92703

Closed
wystans opened this issue Jun 2, 2024 · 4 comments · Fixed by #94114
Closed

Comments

@wystans
Copy link

wystans commented Jun 2, 2024

Tested versions

  • Reproducible in v4.2.2.stable
  • Tested on iOS 17.5.1

System information

Godot v4.2.2.stable - macOS 14.5.0 - Vulkan (Mobile) - integrated Apple M1 Pro - Apple M1 Pro (10 Threads)

Issue description

According to the docs for the LineEdit node, the text_changed signal is "Emitted when the text changes." I would expect that the signal would be emitted once for each letter that is typed in by the user. This works as expected when running on desktop, but does not work correctly on mobile (Tested on iOS 17.5.1).

On mobile, multiple signals are emitted with a subset of the new_text string for each letter that is typed in by the user.

The following is the output of the MRP when typing the letters "Abc" into the LineEdit text box on mobile:

In line_edit_text_changed callback
new_text: A
In line_edit_text_changed callback
new_text:
In line_edit_text_changed callback
new_text: Ab
In line_edit_text_changed callback
new_text: A
In line_edit_text_changed callback
new_text:
In line_edit_text_changed callback
new_text: Abc

The following is the correct/expected output of the same project and input on desktop:

In line_edit_text_changed callback
new_text: A
In line_edit_text_changed callback
new_text: Ab
In line_edit_text_changed callback
new_text: Abc

The main use-case that this interferes with is input validation on mobile for the LineEdit Node.

Steps to reproduce

  1. Download MRP
  2. Export Project -> iOS
  3. Run project on an iOS device from xcode
  4. Type in the LineEdit box and observe the logs for multiple signal emits per letter

Minimal reproduction project (MRP)

line_edit_mobile_bug.zip

@AThousandShips
Copy link
Member

I suspect this is due to how the mobile text input system works inherently, and not necessarily a bug in the engine, if anything it'd possibly be a lack of compensation for this specific behavior, but it might just be a limitation of how phones do input due to things like autocorrect etc. (I don't have an iPhone to try on, but I wouldn't be surprised if the way text input works there is strange compared to a PC where you just have a keyboard, the same might happen with some input processing and IME etc. even on desktop)

@AThousandShips
Copy link
Member

Could be an iOS version of this:

@bruvzg
Copy link
Member

bruvzg commented Jun 2, 2024

That's how iOS (and probably Android) virtual keyboard handling currently works, it's trying to simulate key presses, so when text changes it will send the bunch of Backspace key presses and a new text as a stream of key presses.

IME works in the different way and currently edited text portion is sent via NOTIFICATION_OS_IME_UPDATE (real LineEdit text is not updated), once it's finally committed, it is sent as a stream of key presses as well, but IME will never generate Backspace.

@bruvzg
Copy link
Member

bruvzg commented Jun 2, 2024

We probably should have some sort of direct text update API and avoid key presses in both cases. In addition to unnecessary updates, there were issues on Android with text edit going out of sync with OS virtual keyboard buffer (not sure if it was fully fixed), which are also a result of current approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants