Unity-Technologies / com.unity.uiwidgets

UIWidgets is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
https://unity.cn/uiwidgets
626 stars 78 forks source link

fix text input bug #331

Closed zhuxingwei closed 2 years ago

zhuxingwei commented 2 years ago

In this PR we aims to fix one bug in text input, including:

(1) BUG 1: The way to reproduce the bug is straight-forward: if a user presses keys (e.g., A, B, C) on the keyboard while no editable text is selected, then when he selects an empty editable text and input one letter, (e.g., D), the editable text would become ABCD instead of D. The root cause is that, when the DefaultKeyboardDelegate trying to process the current input (in the method OnGUI()), it will iterate all the input events stored in the queue PointerEventConverter.KeyEvent. Therefore since all the key events would be stored inside the queue even if there is no editable text available to accept them. Once an editable text is activated and trying to accept the current one key event, all the stored (but out-dated) events will be passed to it by mistake.

To fix this issue, we just skip all the key events when no editable text is attached