Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ impl TextEdit<'_> {
atoms.push_right(atom);
}

// Push prefix to the left and enable alignment for the main text
if align.x() != Align::LEFT {
atoms.push_right(Atom::grow());
}

if text.as_str().is_empty() && !hint_text.is_empty() {
// Add hint_text (if any):
let mut shrunk = any_shrink;
Expand All @@ -598,9 +603,7 @@ impl TextEdit<'_> {
first = false;
}

// The hint text should be shown left top instead of centered (important for
// multi line text edits)
atoms.push_right(atom.atom_align(Align2::LEFT_TOP));
atoms.push_right(atom);
}

// Calculate the empty galley, so it can be read later. The available width is
Expand Down Expand Up @@ -643,12 +646,12 @@ impl TextEdit<'_> {
}
})
.atom_id(inner_rect_id)
.atom_shrink(clip_text),
.atom_shrink(true),
);
}

// Ensure the suffix is always right-aligned
if !suffix.is_empty() {
// Push suffix to the right and enable alignment for the main text
if align.x() != Align::RIGHT {
atoms.push_right(Atom::grow());
}

Expand Down
4 changes: 2 additions & 2 deletions crates/egui_demo_app/tests/snapshots/easymarkeditor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/demos/Code Example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/layout/text_edit_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/layout/text_edit_no_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/text_edit_halign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/egui_tests/tests/snapshots/text_edit_rtl_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/text_edit_rtl_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/text_edit_rtl_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/egui_tests/tests/snapshots/visuals/text_edit_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading