-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: TextEdit claims full width even with smaller desired_width #5500
Comments
If this is intended behavior, then there should be some kind of way to set a max "default width" for a |
Egui currently does absolutely nothing with the intrinsic size, it's just set so it can be read e.g. in egui_flex, for advanced layouting. So this issue must be something else. Can you try to make a minimal reproduction? |
I made a discussion about this thinking it was intended but after testing I figured I don't think it is.
Here is my discussion it has a small example including a video. |
Here is a minimal reproduction use eframe::{NativeOptions, egui};
fn main() {
let mut strbuf = String::from(
"Once upon a time there was a very very long string that went out to the store to get some chocolate milk",
);
eframe::run_simple_native("footest", NativeOptions::default(), move |ctx, _frame| {
egui::SidePanel::right("right_panel").show(ctx, |ui| {
ui.text_edit_singleline(&mut strbuf);
});
})
.unwrap();
} |
I did a bisect, and it turns out the cause is #3660 , so I apologize for blaming the wrong pull request. @@ -720,6 +721,16 @@ impl<'t> TextEdit<'t> {
}
}
+ // Allocate additional space if edits were made this frame that changed the size. This is important so that,
+ // if there's a ScrollArea, it can properly scroll to the cursor.
+ let extra_size = galley.size() - rect.size();
+ if extra_size.x > 0.0 || extra_size.y > 0.0 {
+ ui.allocate_rect(
+ Rect::from_min_size(outer_rect.max, extra_size),
+ Sense::hover(),
+ );
+ }
+ |
#5266 makesTextEdit
have an "intrinsic" size, which I'm guessing makes containers expand to the size it reports as intrinsic size.EDIT: #3660 is the cause, see #5500 (comment)
The problem is that it seems to claim the full width of the text, even when
desired_width
is smaller.This causes things like side panels to expand way too far for long text, and possibly flicker a lot if the text width changes.
Here is an example of a
SidePanel::right
expanding way too far (due to very long floating point number displayed in the text edit)desired_width
is set to100.0
in this example case.The text was updated successfully, but these errors were encountered: