diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs
index 8d3f6c9d7be9..b5b3c7d723a8 100644
--- a/crates/eframe/src/web/app_runner.rs
+++ b/crates/eframe/src/web/app_runner.rs
@@ -395,7 +395,10 @@ impl AppRunner {
if self.has_focus() {
// The eframe app has focus.
- if ime.is_some() {
+ if let Some(ime) = ime {
+ if ime.should_interrupt_composition {
+ self.text_agent.interrupt_ime_composition();
+ }
// We are editing text: give the focus to the text agent.
self.text_agent.focus();
} else {
@@ -415,6 +418,12 @@ impl AppRunner {
);
}
}
+
+ #[cfg(debug_assertions)]
+ pub(crate) fn update_custom_debug_information(&mut self) {
+ self.text_agent
+ .update_custom_debug_information(&mut self.input);
+ }
}
// ----------------------------------------------------------------------------
diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs
index ec6bf2a075b1..95cdb8dd01c4 100644
--- a/crates/eframe/src/web/events.rs
+++ b/crates/eframe/src/web/events.rs
@@ -30,6 +30,11 @@ pub(crate) fn paint_and_schedule(runner_ref: &WebRunner) -> Result<(), JsValue>
fn paint_if_needed(runner: &mut AppRunner) {
if runner.needs_repaint.needs_repaint() {
+ #[cfg(debug_assertions)]
+ if !runner.input.raw.events.is_empty() {
+ runner.update_custom_debug_information();
+ }
+
if runner.has_outstanding_paint_data() {
// We have already run the logic, e.g. in an on-click event,
// so let's only present the results:
@@ -190,11 +195,6 @@ pub(crate) fn on_keydown(event: web_sys::KeyboardEvent, runner: &mut AppRunner)
return;
}
- if event.is_composing() || event.key_code() == 229 {
- // https://web.archive.org/web/20200526195704/https://www.fxsitecompat.dev/en-CA/docs/2018/keydown-and-keyup-events-are-now-fired-during-ime-composition/
- return;
- }
-
let modifiers = modifiers_from_kb_event(&event);
runner.input.raw.modifiers = modifiers;
diff --git a/crates/eframe/src/web/text_agent.rs b/crates/eframe/src/web/text_agent.rs
index 60d617d8160a..7559cb591cb3 100644
--- a/crates/eframe/src/web/text_agent.rs
+++ b/crates/eframe/src/web/text_agent.rs
@@ -1,7 +1,10 @@
//! The text agent is a hidden `` element used to capture
//! IME and mobile keyboard input events.
-use std::cell::Cell;
+use std::{
+ cell::{Cell, RefCell},
+ rc::Rc,
+};
use wasm_bindgen::prelude::*;
use web_sys::{Document, Node};
@@ -10,13 +13,171 @@ use super::{AppRunner, WebRunner};
pub struct TextAgent {
input: web_sys::HtmlInputElement,
+ input_state: Rc>,
prev_ime_output: Cell