Skip to content

Commit

Permalink
Add support for opening egui links in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Oct 9, 2022
1 parent d2512c2 commit 6741215
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["opengl"]
default = ["opengl", "links"]
opengl = ["egui_glow", "baseview/opengl"]
links = ["webbrowser"]

[dependencies]
egui = "0.19"
egui_glow = { version = "0.19", optional = true }
keyboard-types = { version = "0.6.1", default-features = false }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "eae4033e7d2cc9c31ccaa2794d5d08eedf2f510c" }
baseview = { path = "../baseview" }
raw-window-handle = "0.4.2"
copypasta = "0.8"
webbrowser = { version = "0.8", optional = true }
8 changes: 8 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ where
self.repaint_after = Some(repaint_after);
}

if let Some(open_url) = platform_output.open_url {
open_url_in_browser(&open_url.url);
}
if !platform_output.copied_text.is_empty() {
if let Some(clipboard_ctx) = &mut self.clipboard_ctx {
if let Err(err) = clipboard_ctx.set_contents(platform_output.copied_text) {
Expand Down Expand Up @@ -626,3 +629,8 @@ fn is_paste_command(modifiers: egui::Modifiers, keycode: keyboard_types::Code) -
&& modifiers.shift
&& keycode == keyboard_types::Code::Insert)
}

fn open_url_in_browser(_url: &str) {
#[cfg(feature = "webbrowser")]
let _ = webbrowser::open(_url);
}

0 comments on commit 6741215

Please sign in to comment.