diff --git a/src/lib.rs b/src/lib.rs index 8509ef522..00e25a46e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,11 +101,19 @@ pub struct EguiSettings { /// } /// ``` pub scale_factor: f64, + /// Will be used as a default value for hyperlink [target](https://www.w3schools.com/tags/att_a_target.asp) hints. + /// If not specified, `_self` will be used. Only matters in a web browser. + #[cfg(feature = "open_url")] + pub default_open_url_target: Option, } impl Default for EguiSettings { fn default() -> Self { - Self { scale_factor: 1.0 } + Self { + scale_factor: 1.0, + #[cfg(feature = "open_url")] + default_open_url_target: None, + } } } diff --git a/src/systems.rs b/src/systems.rs index dbb69953d..e48439738 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -327,6 +327,9 @@ pub fn begin_frame( } pub fn process_output( + #[cfg_attr(not(feature = "open_url"), allow(unused_variables))] egui_settings: Res< + EguiSettings, + >, mut egui_context: ResMut, mut egui_output: ResMut>, mut egui_render_output: ResMut>, @@ -369,7 +372,14 @@ pub fn process_output( #[cfg(feature = "open_url")] if let Some(egui::output::OpenUrl { url, new_tab }) = platform_output.open_url { - let target = if new_tab { "_blank" } else { "_self" }; + let target = if new_tab { + "_blank" + } else { + egui_settings + .default_open_url_target + .as_deref() + .unwrap_or("_self") + }; if let Err(err) = webbrowser::open_browser_with_options( webbrowser::Browser::Default, &url,