Skip to content
Merged
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
8 changes: 7 additions & 1 deletion crates/egui/src/widgets/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,14 @@ impl Widget for Label {

if ui.is_rect_visible(response.rect) {
if show_tooltip_when_elided && galley.elided {
// Keep the sections and text, but reset everything else (especially wrapping):
let job = crate::text::LayoutJob {
sections: galley.job.sections.clone(),
text: galley.job.text.clone(),
..crate::text::LayoutJob::default()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

};
// Show the full (non-elided) text on hover:
response = response.on_hover_text(galley.job.clone());
response = response.on_hover_text(job);
}

let response_color = if interactive {
Expand Down
2 changes: 1 addition & 1 deletion tests/egui_tests/tests/regression_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn hovering_should_preserve_text_format() {
let mut harness = Harness::builder().with_size((200.0, 70.0)).build_ui(|ui| {
ui.add(
Label::new(
RichText::new("Long text that should be elided and has lots of styling")
RichText::new("Long text that should be elided and has lots of styling and is long enough to have multiple lines.")
.italics()
.underline()
.color(Color32::LIGHT_BLUE),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading