Skip to content

Commit efda407

Browse files
committed
fix: IME input issue on new input system
1 parent d4462b8 commit efda407

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Assets/Scripts/Core/Text/InputTextField.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,11 @@ bool HandleKey(InputEvent evt)
14011401
{
14021402
#if FAIRYGUI_INPUT_SYSTEM
14031403
if (!evt.ctrlOrCmd && (c == '\n' || c == '\r' || c == '\t' || c == 25 || c == 3))
1404+
{
1405+
_keydownFrame = Time.frameCount;
1406+
_keydownChar = c;
14041407
HandleTextInput(c);
1408+
}
14051409
#else
14061410
if (!evt.ctrlOrCmd)
14071411
HandleTextInput(c);
@@ -1528,6 +1532,8 @@ public static string compositionString
15281532

15291533
#else
15301534
static string _compositionString = string.Empty;
1535+
static int _keydownFrame;
1536+
static char _keydownChar;
15311537

15321538
public static void RegisterEvent()
15331539
{
@@ -1569,13 +1575,17 @@ static void OnIMECompositionChange(IMECompositionString composition)
15691575

15701576
static void OnTextInput(char c)
15711577
{
1572-
// filter control chars
1573-
// if Active input handling is BOTH, we will receive these controls chars in this callback
1574-
// howeveer, if Active input handling is New, we will not receive these controls chars in this callback
1575-
if (c < 32 && c != 3 && c != '\t' && c != '\n' && c != '\r' && c != 25
1576-
|| c >= 127 && c <= 159
1577-
|| c >= 63232 && c <= 63235//why arrow keys have these codes?
1578-
)
1578+
Keyboard keyboard = Keyboard.current;
1579+
if (keyboard.ctrlKey.isPressed || Keyboard.current.altKey.isPressed
1580+
|| keyboard.leftCommandKey.isPressed || keyboard.rightCommandKey.isPressed
1581+
)
1582+
return;
1583+
1584+
if (_keydownFrame == Time.frameCount && _keydownChar == c)
1585+
return;
1586+
1587+
if (c < 32 || c >= 127 && c <= 159
1588+
|| c >= 0xF700 && c <= 0xF7FF /*why home/end/arrow-keys have these codes?*/)
15791589
return;
15801590

15811591
var focus = Stage.inst.focus;

0 commit comments

Comments
 (0)