Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

CJK IME: In the parameter brackets of an expression, the first character entered will be repeated #8227

Open XHXIAIEIN opened 1 month ago

XHXIAIEIN commented 1 month ago

Problem description

This question is a secondary question caused by the https://github.com/Scirra/Construct-bugs/issues/7988

In the parameter brackets of an expression, the first character entered will be duplicate. It is reproduced anywhere non-English string When using IME.

Snipaste_2024-09-17_18-08-57


a possible line of investigation: https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event

Attach a .c3p

issue-ime2.c3p.zip

Steps to reproduce

Any expression can be reproduced, use IME to input any characters in brackets. Note: | indicates the position of the cursor

  1. abs()|
  2. abs(|)
  3. abs(qu|)
  4. it will automatically become abs(qqu|)

Observed result

input: jing Observed: jjing

Snipaste_2024-09-17_18-08-57


Snipaste_2024-09-17_18-09-20 Snipaste_2024-09-17_18-09-34

Expected result

no additional repeated characters

More details

Affected browsers/platforms:

First affected release:

System details

View details PASTE HERE
AshleyScirra commented 2 weeks ago

I'm afraid I can't reproduce this. Normally I test IME issues using the Windows emoji picker, as that appears to fire the same compositionstart/end events as IME uses. If I follow these steps:

  1. Type abs(
  2. Press Windows + . to show emoji picker
  3. Choose 😀 from picker

Then it correctly enters abs(😀 - there is no duplication. I verified it is firing compositionstart/end events so it doesn't appear those are doing anything wrong.

The input is in fact a contenteditable field and the browser itself handles entering characters - Construct only responds to the entered input and doesn't handle actually adding characters itself (unless you do something like choose an expression from the Expressions Dictionary or select an autocomplete suggestion). So it may be a browser bug or issue with the type of IME you are using.

Do you have any further advice on how to reproduce the problem?

XHXIAIEIN commented 2 weeks ago

I tried it and the error still occurs. The steps to reproduce are not like this

1 Open Settings Time & language image

2 Add a language. image

3 Search 'Chinese' and select the first one image

4 You don't need to check them. image

5 Download... image

6 Press Windows + space to toggle IME, Or click this icon in the taskbar. image

7 Then you will see an icon like this, indicating that you have switched to the Pinyin IME. image

8 If you want to toggle English, you can press Shift to switch between Chinese and English. image


Let's return to this issues again.

1 It needs to be in closed brackets. image

2 input 'jing', it will become 'jjing' image

XHXIAIEIN commented 2 weeks ago

I think another possible solution to investigate is to design "throttle" and "debounce" functions the input events. https://medium.com/@mujaffarhssn/debouncing-vs-throttling-optimizing-your-javascript-for-performance-a99d38f5eb3b