Skip to content

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor#7916

Open
rustbasic wants to merge 1 commit intoemilk:mainfrom
rustbasic:patch169
Open

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor#7916
rustbasic wants to merge 1 commit intoemilk:mainfrom
rustbasic:patch169

Conversation

@rustbasic
Copy link
Contributor

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor

Problem

In WASM/Web environments, egui provides IMEOutput to the browser to handle IME composition and mobile text input. The browser creates an invisible text agent (like a hidden <textarea>) based on the provided cursor_rect.

However, this hidden element often possesses a small physical hitbox (especially to the right of the cursor). This causes a bug where mouse clicks occurring slightly to the right of the text cursor are intercepted by the browser's hidden element and never reach the egui canvas, resulting in "dead zones" for user interaction.

Solution

This PR modifies the cursor_rect passed to IMEOutput to be a zero-width Rect (tiny_rect).

  • By setting the size to Vec2::ZERO, the browser's invisible agent no longer has a clickable area, ensuring all pointer events are correctly delivered to the egui canvas.
  • The left_top position is preserved, so IME candidate windows (like Hanja or Emoji pickers) still appear at the correct coordinate relative to the cursor.

Impact

  • Fixed: Clicking near/on the text cursor in TextEdit (WASM) is now 100% reliable.
  • No Regression: IME functionality remains intact as the positional anchor is unchanged.

…near cursor

#### Problem
In WASM/Web environments, `egui` provides `IMEOutput` to the browser to handle IME composition and mobile text input. The browser creates an invisible text agent (like a hidden `<textarea>`) based on the provided `cursor_rect`. 

However, this hidden element often possesses a small physical hitbox (especially to the right of the cursor). This causes a bug where mouse clicks occurring slightly to the right of the text cursor are intercepted by the browser's hidden element and never reach the `egui` canvas, resulting in "dead zones" for user interaction.

#### Solution
This PR modifies the `cursor_rect` passed to `IMEOutput` to be a zero-width `Rect` (`tiny_rect`). 
- By setting the size to `Vec2::ZERO`, the browser's invisible agent no longer has a clickable area, ensuring all pointer events are correctly delivered to the `egui` canvas.
- The `left_top` position is preserved, so IME candidate windows (like Hanja or Emoji pickers) still appear at the correct coordinate relative to the cursor.

#### Impact
- **Fixed:** Clicking near/on the text cursor in `TextEdit` (WASM) is now 100% reliable.
- **No Regression:** IME functionality remains intact as the positional anchor is unchanged.
@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Preview available at https://egui-pr-preview.github.io/pr/7916-patch169
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

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.

1 participant