Skip to content

Commit

Permalink
Don't show URLs when hovering hyperlinks
Browse files Browse the repository at this point in the history
Can be changed with `Style::url_in_tooltip`
  • Loading branch information
emilk committed Mar 23, 2024
1 parent 20b0637 commit 14ed28b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ pub struct Style {
/// This only affects a few egui widgets.
pub explanation_tooltips: bool,

/// Show the URL of hyperlinks in a tooltip when hovered.
pub url_in_tooltip: bool,

/// If true and scrolling is enabled for only one direction, allow horizontal scrolling without pressing shift
pub always_scroll_the_only_direction: bool,
}
Expand Down Expand Up @@ -1212,6 +1215,7 @@ impl Default for Style {
#[cfg(debug_assertions)]
debug: Default::default(),
explanation_tooltips: false,
url_in_tooltip: false,
always_scroll_the_only_direction: false,
}
}
Expand Down Expand Up @@ -1474,6 +1478,7 @@ impl Style {
#[cfg(debug_assertions)]
debug,
explanation_tooltips,
url_in_tooltip,
always_scroll_the_only_direction,
} = self;

Expand Down Expand Up @@ -1544,6 +1549,8 @@ impl Style {
"Show explanatory text when hovering DragValue:s and other egui widgets",
);

ui.checkbox(url_in_tooltip, "Show url when hovering links");

ui.checkbox(always_scroll_the_only_direction, "Always scroll the only enabled direction")
.on_hover_text(
"If scrolling is enabled for only one direction, allow horizontal scrolling without pressing shift",
Expand Down
7 changes: 6 additions & 1 deletion crates/egui/src/widgets/hyperlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ impl Widget for Hyperlink {
new_tab: true,
});
}
response.on_hover_text(url)

if ui.style().url_in_tooltip {
response.on_hover_text(url)
} else {
response
}
}
}

0 comments on commit 14ed28b

Please sign in to comment.