Skip to content

Backspace not working in the text edit when the user enters text the very first time. #446

@leungkkf

Description

@leungkkf

I have an issue with the text edit in native Linux that when the user enters text the very first time, the backspace doesn't work. It seems to be related to an IME issue in native Linux. Egui has changed the code a bit to fix this.

It seems that the bevy_egui is a bit out of sync.

Steps to repro:

[package]
name = "bevy_egui_test"
version = "0.1.0"
edition = "2024"

[dependencies]
bevy = "0.17.0"
bevy_egui = "0.38.0"

use bevy::prelude::*;
use bevy_egui::{EguiContexts, EguiPlugin, EguiPrimaryContextPass, egui};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EguiPlugin::default())
        .add_systems(Startup, setup_camera_system)
        .add_systems(EguiPrimaryContextPass, ui_example_system)
        .run();
}

fn setup_camera_system(mut commands: Commands) {
    commands.spawn(Camera2d);
}

fn ui_example_system(mut contexts: EguiContexts, mut text: Local<String>) -> Result {
    egui::Window::new("Hello").show(contexts.ctx_mut()?, |ui| {
        ui.label("world");
        let text = &mut (*text);
        if ui.text_edit_singleline(text).changed() {
            println!("{text}");
        }
    });
    Ok(())
}

In native Linux,

  1. Click on the text edit and enter some text.
  2. Press backspace to try to delete some characters.
  3. Nothing happens.

Expected behaviour:

Pressing backspace should delete the characters at the end.

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions