Skip to content

Delegate handling of IME interruptions to integrations to fix virtual keyboard flickering on web#8078

Merged
emilk merged 5 commits intoemilk:mainfrom
umajho:let-integration-interrupt-ime-v2
Apr 8, 2026
Merged

Delegate handling of IME interruptions to integrations to fix virtual keyboard flickering on web#8078
emilk merged 5 commits intoemilk:mainfrom
umajho:let-integration-interrupt-ime-v2

Conversation

@umajho
Copy link
Copy Markdown
Contributor

@umajho umajho commented Apr 7, 2026

Details

In #7983, I modified Memory::request_focus to interrupt any ongoing IME composition. This fixed a bug where clicking inside an already focused TextEdit failed to cancel the active composition, resulting in duplicated text:

#8045 (comment)

To avoid introducing API changes in that PR, I ensured the IME state was reset by forcing PlatformOutput::ime to None for at least one frame.
While this works well on desktop platforms, it causes virtual keyboard flickering on the web:

#8045 (comment)

In this PR, I delegate the responsibility for handling IME composition interruptions to integrations, allowing each integration to decide how to interrupt compositions in a flexible manner.

The new field should_interrupt_composition on IMEOutput.

Instead of introducing a new OutputCommand variant, this PR adds a new field should_interrupt_composition to IMEOutput.

Interrupting an active composition is only meaningful when IME remains allowed. If IME should be disabled altogether, PlatformOutput::ime can simply be set to None.
Given this, IMO, it is more appropriate to attach the interrupt signal to IMEOutput (i.e., the type of PlatformOutput::ime).

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Preview available at https://egui-pr-preview.github.io/pr/8078-let-integration-interrupt-ime-v2
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

@umajho umajho marked this pull request as ready for review April 7, 2026 17:05
In the first version of this PR, I moved `owns_ime_events` and `interrupt_ime`
from `Memory` to `Context`. This change casued `Memory::request_focus` to lose
the access to `interrupt_ime`, so I introduced an alernative way to detect
interactions that interrupt IME composition.

Upon further consideration, I found that this refactor was unnecesscarily
large. I reworked the approach without moving those methods, which let to the
current version of this PR.

During the rework, I overlooked that `request_focus` now calls `interrupt_ime`
again, therefore the additional interaction checks became redundant. This
commit removes those checks.
@umajho umajho changed the title Let integrations handle IME interruptions to fix virtual keyboard flickering on web Delegate responsibility for handling IME interruptions to integrations to fix virtual keyboard flickering on web Apr 7, 2026
@umajho umajho changed the title Delegate responsibility for handling IME interruptions to integrations to fix virtual keyboard flickering on web Delegate handling of IME interruptions to integrations to fix virtual keyboard flickering on web Apr 7, 2026
@cjgriscom
Copy link
Copy Markdown

cjgriscom commented Apr 7, 2026

This solves the flickering on my end. And seems like a good solution

@emilk emilk added web Related to running Egui on the web eframe Relates to epi and eframe text Problems related to text IME labels Apr 8, 2026
@emilk emilk added egui-winit porblems related to winit and removed text Problems related to text labels Apr 8, 2026
@emilk emilk merged commit 86a7f47 into emilk:main Apr 8, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eframe Relates to epi and eframe egui-winit porblems related to winit IME web Related to running Egui on the web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants