Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit 6741215

Browse files
committed
Add support for opening egui links in browser
1 parent d2512c2 commit 6741215

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ readme = "README.md"
1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

1616
[features]
17-
default = ["opengl"]
17+
default = ["opengl", "links"]
1818
opengl = ["egui_glow", "baseview/opengl"]
19+
links = ["webbrowser"]
1920

2021
[dependencies]
2122
egui = "0.19"
2223
egui_glow = { version = "0.19", optional = true }
2324
keyboard-types = { version = "0.6.1", default-features = false }
24-
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c" }
25+
baseview = { path = "../baseview" }
2526
raw-window-handle = "0.4.2"
2627
copypasta = "0.8"
28+
webbrowser = { version = "0.8", optional = true }

src/window.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ where
327327
self.repaint_after = Some(repaint_after);
328328
}
329329

330+
if let Some(open_url) = platform_output.open_url {
331+
open_url_in_browser(&open_url.url);
332+
}
330333
if !platform_output.copied_text.is_empty() {
331334
if let Some(clipboard_ctx) = &mut self.clipboard_ctx {
332335
if let Err(err) = clipboard_ctx.set_contents(platform_output.copied_text) {
@@ -626,3 +629,8 @@ fn is_paste_command(modifiers: egui::Modifiers, keycode: keyboard_types::Code) -
626629
&& modifiers.shift
627630
&& keycode == keyboard_types::Code::Insert)
628631
}
632+
633+
fn open_url_in_browser(_url: &str) {
634+
#[cfg(feature = "webbrowser")]
635+
let _ = webbrowser::open(_url);
636+
}

0 commit comments

Comments
 (0)