Skip to content

egui::Grid not allowing widgets to scale. #4686

Answered by YgorSouza
Jonne-G asked this question in Q&A
Discussion options

You must be logged in to vote

There are plans to improve layout for these kinds of cases, but one way to make this work with the current version of egui is to use add_sized to set the size of the first row, and then the other rows will follow (as long as the default size is large enough).

let text_width = 200.0;
ui.spacing_mut().text_edit_width = text_width;
egui::Grid::new("my_grid").show(ui, |ui| {
    ui.label("Short");
    let mut size = ui.spacing().interact_size;
    size.x = text_width;
    ui.add_sized(size, |ui: &mut egui::Ui| {
        ui.text_edit_singleline(&mut self.name)
    });
    ui.button("icon");
    ui.end_row();

    ui.label("Longer string");
    ui.text_edit_singleline(&mut self.name);
    ui.bu…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Jonne-G
Comment options

Comment options

You must be logged in to vote
1 reply
@Jonne-G
Comment options

Answer selected by Jonne-G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants