emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.61k stars 1.49k forks source link

Putting an `TextEdit` in a `egui::Grid` makes it too small #4694

Open emilk opened 5 days ago

emilk commented 5 days ago

Discussed in https://github.com/emilk/egui/discussions/4686

Originally posted by **Jonne-G** June 21, 2024 Hi all, I'm trying to make an input dialogue using the egui::Grid layout as a means to keep all the widgets aligned. The problem is, that somehow the TextEdit is not properly resizing. This is roughly the code I'm using to achieve this: ```rust Grid::new("my_grid").show(ui, |ui| { ui.label("1st Executable"); ui.text_edit_singleline(&mut path_1); ui.button("icon"); ui.end_row(); ui.label("2nd Executable"); ui.text_edit_singleline(&mut path_2); ui.button("icon"); ui.end_row(); ui.separator(); ui.end_row(); ui.label("Install Directory"); ui.text_edit_singleline(&mut path_3); ui.button("icon"); ui.end_row(); }); ``` As well as the visuals it produces: ![faulty_paths](https://github.com/emilk/egui/assets/60442130/f3fd8b58-86ec-4095-8d64-bb252ed67c21) I have tried using the `.desired_width()` method on the TextEdit to force it to a certain size, but even then it still stays miniscule. To add the desired width, this is what I tried using: ```rust ui.label("1st Executable"); // I have tried with both infinity, and just a high value, neither seem to work. let edit = TextEdit::singleline(&mut path_1).desired_width(f32::INFINITY); ui.add(edit); ui.button("icon"); ui.end_row(); ```