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

Fix Korean text input #406

Merged
merged 2 commits into from
Feb 23, 2023
Merged

Fix Korean text input #406

merged 2 commits into from
Feb 23, 2023

Conversation

igordmn
Copy link
Collaborator

@igordmn igordmn commented Feb 14, 2023

Fixes JetBrains/compose-multiplatform#2600

  1. We shouldn't skip input events with empty text, they will clear the current uncommitted text. In case of Korean, Swing will send a clear event of the previous char when we press Space, and send a separate "KEY_TYPED" event for the last character:
  • press q -> q uncommitted
  • press w -> commit q, w uncommitted
  • press Space -> discard committed text (event with empty text), send KEY_TYPED event with w and KEY_TYPED event with Space
  1. Add tests for test input. I traced Swing events on each OS to mimic integration tests (It is difficult to write real input tests)

Fixes JetBrains/compose-multiplatform#2600

1. We shouldn't skip input events with empty text, they will clear the current uncommitted text. In case of Korean, Swing will send a clear event of the previous char when we press Space, and send a separate "KEY_TYPED" event for the last character:
- press q -> q uncommitted
- press w -> commit q, w uncommitted
- press Space -> discard committed text (event with empty text), send KEY_TYPED event with w and KEY_TYPED event with Space

2. Add tests for test input. I traced Swing events on each OS to mimic integration tests (It is difficult to write real input tests)
platform.textInputService.onInputEvent(event)
}
}
// Which OSes and which input method could produce such events? We need to have some
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should ask someone knowledgeable? I bet it's not here for nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be only for Swing components. This method isn't triggered on Linux/Windows/macOS

I created a separate issue that can be related to this: JetBrains/compose-multiplatform#2758

}

@Test
fun `q, w, backspace 3x (Chinese, macOS)`() = runTypeTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test name mentions the OS (macOS in this case).
But how does the test actually configure the OS? what is the difference in tests for different OS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems I see the difference. Every test sends the sequence of key events. Such sequences are different for different OS.

So it's not necessary to specify/configure the OS specific things for the test, beside sending the OS-specifc key event sequence. So these tests may run on any OS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment in the description of class.

The name of OS is important information.

@igordmn igordmn merged commit 7b7b28a into jb-main Feb 23, 2023
@igordmn igordmn deleted the fix-korean-language branch February 23, 2023 12:55
eymar pushed a commit that referenced this pull request Feb 24, 2023
Fixes JetBrains/compose-multiplatform#2600

1. We shouldn't skip input events with empty text, they will clear the current uncommitted text. In case of Korean, Swing will send a clear event of the previous char when we press Space, and send a separate "KEY_TYPED" event for the last character:
- press q -> q uncommitted
- press w -> commit q, w uncommitted
- press Space -> discard committed text (event with empty text), send KEY_TYPED event with w and KEY_TYPED event with Space

2. Add tests for test input. I traced Swing events on each OS to mimic integration tests (It is difficult to write real input tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compose(DESKTOP,JVM) 1.2.2 textfield Korean duplication
3 participants