-
Notifications
You must be signed in to change notification settings - Fork 2k
IME (CJK) commitment with Enter key causes unintended newline in multiline TextEdit #7876
Description
Describe the bug
In egui::TextEdit::multiline, when using an IME (Input Method Editor) for CJK languages (Chinese, Japanese, Korean), pressing the Enter key to commit the preedit string results in an unintended newline (\n) being inserted into the text buffer.
The Enter key should only be used to commit the composition, but egui (or the underlying winit) appears to process it as a physical "New Line" command simultaneously.
Minimal Reproducible Example
// This is the most basic code to reproduce the issue.
// No extra key handling or custom logic is involved.
ui.add(egui::TextEdit::multiline(&mut self.text));
// The problem:
// In CJK IME, one Enter key press results in:
// 1. ImeEvent::Commit (Correct)
// 2. Event::Key { key: Enter, .. } + Event::Text("\n") (Incorrect)
Steps to reproduce
- Use
eguion Windows/macOS with a CJK IME enabled. - Focus on a
TextEdit::multilinefield. - Type characters to start an IME composition (Preedit state).
- Press Enter to commit the composition.
- Observed Behavior: The characters are committed, but a newline is added immediately after them.
Technical Findings
Based on event monitoring:
- During the commitment frame,
eguireceives both the committed text and aKey::Enterpress event. - Even when the IME is supposed to "consume" the Enter key for commitment, the event leaks through as a text input of
\n. - This makes it impossible to implement a standard CJK writing experience where Enter only commits text without jumping to the next line.
Expected behavior
The Enter key event used for IME commitment should be suppressed or consumed, ensuring that \n is only inserted when the user explicitly intends to create a new line (i.e., when no composition is active or via a specific modifier).
Environment
- egui version: 0.33.3
- OS: Windows / macOS (IME issues are common across both)