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

Commit 3bc457e

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

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ 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"
@@ -24,3 +25,4 @@ keyboard-types = { version = "0.6.1", default-features = false }
2425
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c" }
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)