-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a workaround for the app freezing because of bfcache (see bevyengine/bevy#10328).
- Loading branch information
1 parent
be4d3af
commit 45c78f8
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use bevy_egui::egui::{Link, Widget, WidgetText}; | ||
|
||
/// Clickable hyperlink, same as [`bevy_egui::egui::Hyperlink`] but it always | ||
/// opens the url in a new tab. | ||
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] | ||
pub struct NewTabHyperlink { | ||
url: &'static str, | ||
text: WidgetText, | ||
} | ||
|
||
impl NewTabHyperlink { | ||
pub fn from_label_and_url(text: impl Into<WidgetText>, url: &'static str) -> Self { | ||
Self { | ||
url, | ||
text: text.into(), | ||
} | ||
} | ||
} | ||
impl Widget for NewTabHyperlink { | ||
fn ui(self, ui: &mut bevy_egui::egui::Ui) -> bevy_egui::egui::Response { | ||
let Self { url, text } = self; | ||
|
||
let response = ui.add(Link::new(text)); | ||
if response.clicked() | response.middle_clicked() { | ||
ui.ctx().output_mut(|o| { | ||
o.open_url = Some(bevy_egui::egui::output::OpenUrl { | ||
url: url.to_string(), | ||
new_tab: true, | ||
}); | ||
}); | ||
} | ||
response.on_hover_text(url) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters