pub fn write_ime_events_system(
    focused_non_window_egui_context: Option<Res<FocusedNonWindowEguiContext>>,
    mut ime_reader: EventReader<Ime>,
    mut egui_input_event_writer: EventWriter<EguiInputEvent>,
    mut egui_contexts: Query<
        (
            Entity,
            &EguiContextSettings,
            &mut EguiContextImeState,
            &EguiOutput,
        ),
        With<EguiContext>,
    >,
) {
    for event in ime_reader.read() {
        let window = match &event {
            Ime::Preedit { window, .. }
            | Ime::Commit { window, .. }
            | Ime::Disabled { window }
            | Ime::Enabled { window } => *window,
        };
        let context = focused_non_window_egui_context
            .as_deref()
            .map_or(window, |context| context.0);

        let Some((_entity, context_settings, mut ime_state, _egui_output)) =
            egui_contexts.get_some_mut(context)
        else {
            continue;
        };

        if !context_settings
            .input_system_settings
            .run_write_ime_events_system
        {
            continue;
        }

        let ime_event_enable =
            |ime_state: &mut EguiContextImeState,
             egui_input_event_writer: &mut EventWriter<EguiInputEvent>| {
                if !ime_state.has_sent_ime_enabled {
                    egui_input_event_writer.write(EguiInputEvent {
                        context,
                        event: egui::Event::Ime(egui::ImeEvent::Enabled),
                    });
                    ime_state.has_sent_ime_enabled = true;
                }
            };

        let ime_event_disable =
            |ime_state: &mut EguiContextImeState,
             egui_input_event_writer: &mut EventWriter<EguiInputEvent>| {
                if !ime_state.has_sent_ime_enabled {
                    egui_input_event_writer.write(EguiInputEvent {
                        context,
                        event: egui::Event::Ime(egui::ImeEvent::Disabled),
                    });
                    ime_state.has_sent_ime_enabled = false;
                }
            };

        // Aligned with the egui-winit implementation: https://github.com/emilk/egui/blob/0f2b427ff4c0a8c68f6622ec7d0afb7ba7e71bba/crates/egui-winit/src/lib.rs#L348
        match event {
            Ime::Enabled { window: _ } => {
                ime_event_enable(&mut ime_state, &mut egui_input_event_writer);
            }
            Ime::Preedit {
                value,
                window: _,
                cursor: _,
            } => {
                ime_event_enable(&mut ime_state, &mut egui_input_event_writer);
                egui_input_event_writer.write(EguiInputEvent {
                    context,
                    event: egui::Event::Ime(egui::ImeEvent::Preedit(value.clone())),
                });
            }
            Ime::Commit { value, window: _ } => {
                egui_input_event_writer.write(EguiInputEvent {
                    context,
                    event: egui::Event::Ime(egui::ImeEvent::Commit(value.clone())),
                });
                ime_event_disable(&mut ime_state, &mut egui_input_event_writer);
            }
            Ime::Disabled { window: _ } => {
                ime_event_disable(&mut ime_state, &mut egui_input_event_writer);
            }
        }
    }
}
Reads [`Ime`] events and wraps them into [`EguiInputEvent`], can redirect events to [`FocusedNonWindowEguiContext`].
src/input.rs