From 68c205db43b3ce7c0581bd95cf8c3fbc14165003 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Wed, 16 Oct 2024 16:40:34 +0200 Subject: [PATCH] Fix textedit intrinsic size metric --- crates/egui/src/widgets/text_edit/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 12e92b904a6..49eb9fc3e9f 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -525,13 +525,13 @@ impl<'t> TextEdit<'t> { let mut galley = layouter(ui, text.as_str(), wrap_width); - let desired_width = if clip_text { + let desired_inner_width = if clip_text { wrap_width // visual clipping with scroll in singleline input. } else { galley.size().x.max(wrap_width) }; let desired_height = (desired_height_rows.at_least(1) as f32) * row_height; - let desired_inner_size = vec2(desired_width, galley.size().y.max(desired_height)); + let desired_inner_size = vec2(desired_inner_width, galley.size().y.max(desired_height)); let desired_outer_size = (desired_inner_size + margin.sum()).at_least(min_size); let (auto_id, outer_rect) = ui.allocate_space(desired_outer_size); let rect = outer_rect - margin; // inner rect (excluding frame/margin). @@ -562,7 +562,7 @@ impl<'t> TextEdit<'t> { Sense::hover() }; let mut response = ui.interact(outer_rect, id, sense); - response.intrinsic_size = Some(desired_outer_size); + response.intrinsic_size = Some(Vec2::new(desired_width, desired_outer_size.y)); response.fake_primary_click = false; // Don't sent `OutputEvent::Clicked` when a user presses the space bar