Skip to content

Commit

Permalink
Warn when trying to open a link and the links feature is not on
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 25, 2021
1 parent 79f9e2f commit 0fcb645
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions egui_for_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,8 @@ impl State {

self.set_cursor_icon(window, output.cursor_icon);

#[cfg(feature = "webbrowser")]
if let Some(open) = output.open_url {
if let Err(err) = webbrowser::open(&open.url) {
eprintln!("Failed to open url: {}", err);
}
self.open_url(open.url);
}

if !output.copied_text.is_empty() {
Expand Down Expand Up @@ -476,6 +473,18 @@ impl State {
window.set_cursor_visible(false);
}
}

fn open_url(&mut self, _url: String) {
#[cfg(feature = "webbrowser")]
if let Err(err) = webbrowser::open(&_url) {
eprintln!("Failed to open url: {}", err);
}

#[cfg(not(feature = "webbrowser"))]
{
eprintln!("Cannot open url - feature \"links\" not enabled.");
}
}
}

/// Glium sends special keys (backspace, delete, F1, ...) as characters.
Expand Down

0 comments on commit 0fcb645

Please sign in to comment.