Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor#7916
Open
rustbasic wants to merge 1 commit intoemilk:mainfrom
Open
Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor#7916rustbasic wants to merge 1 commit intoemilk:mainfrom
rustbasic wants to merge 1 commit intoemilk:mainfrom
Conversation
…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.
|
Preview available at https://egui-pr-preview.github.io/pr/7916-patch169 View snapshot changes at kitdiff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor
Problem
In WASM/Web environments,
eguiprovidesIMEOutputto the browser to handle IME composition and mobile text input. The browser creates an invisible text agent (like a hidden<textarea>) based on the providedcursor_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
eguicanvas, resulting in "dead zones" for user interaction.Solution
This PR modifies the
cursor_rectpassed toIMEOutputto be a zero-widthRect(tiny_rect).Vec2::ZERO, the browser's invisible agent no longer has a clickable area, ensuring all pointer events are correctly delivered to theeguicanvas.left_topposition is preserved, so IME candidate windows (like Hanja or Emoji pickers) still appear at the correct coordinate relative to the cursor.Impact
TextEdit(WASM) is now 100% reliable.