NemuiSen / ggegui

A simple implementation of egui for ggez
51 stars 29 forks source link

TextEdit requiring text_input_event on EventHandler #42

Closed JeanNicolasdeLamballerie closed 1 month ago

JeanNicolasdeLamballerie commented 1 month ago

When trying to implement TextEdit :

let resp = panel_ui.add(egui::TextEdit::singleline(&mut g_config.new_profile_name));
println!("ch : {}", resp.changed());

Only deleting characters triggers changed() with the backspace.

After looking around my code, I suspected that this was because ggez was the one detecting the inputs ; and a quick look through your examples confirmed my suspicions, as I found the text_input_event() example that worked like a charm by adding it to the EventHandler and giving back the characters to gui.

Considering this is very specific to the interaction between egui and ggez, it might be worth to add this into the Readme example ? It feels a little counterintuitive that the inputs would only partially work, and even if the solution would be found eventually, I initially spent a little while thinking I was dealing with either a broken part of the library, or that it was my implementation of the UI that was wrong, when it was in fact related to ggez and not to egui.

NemuiSen commented 1 month ago

Yes, it's my fault, I forgot to add a note about that. Thanks for reminding me