Fix: hint text follows the alignment set on the `TextEdit` (#4889)
Updated the `show_content` method of the `TextEdit` widget so that the requested text alignment (if any) is also applied to the hint text. Currently, hint text is always aligned to the top left of the widget, which may be inconsistent with the actual location of text entered by the user. I think it's more intuitive for the hint text to be positioned as if the user had entered the same text themselves. Here are some comparisons of the difference between how the hint text and the entered text looks, before and after this change: ### Previous Behaviour  ### Updated Behaviour  * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
7736192722
commit
37b1e1504d
|
|
@ -682,7 +682,11 @@ impl<'t> TextEdit<'t> {
|
|||
hint_text_font_id,
|
||||
)
|
||||
};
|
||||
painter.galley(rect.min, galley, hint_text_color);
|
||||
let galley_pos = align
|
||||
.align_size_within_rect(galley.size(), rect)
|
||||
.intersect(rect)
|
||||
.min;
|
||||
painter.galley(galley_pos, galley, hint_text_color);
|
||||
}
|
||||
|
||||
if ui.memory(|mem| mem.has_focus(id)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue