asny / three-d

2D/3D renderer - makes it simple to draw stuff across platforms (including web)
MIT License
1.24k stars 105 forks source link

`egui` links don't work? #460

Closed joshburkart closed 1 week ago

joshburkart commented 1 month ago

When I try to make a hyperlink in an egui GUI, it renders, but I can't seem to make the link actually work, i.e. clicking it does nothing. This occurs for me both in WebGL and in a native app on my Mac laptop (latest Sonoma MacOS).

Example based on the environment example:

  1. Added a link:

    Screenshot 2024-05-28 at 4 32 39 PM
  2. Link renders fine:

    Screenshot 2024-05-28 at 4 39 55 PM
  3. Nothing happens when I click on it though :(

Thank you for making this excellent package, I really enjoyed using it!

joshburkart commented 1 week ago

Needed to add the following blurb inside the callback argument to gui.update:

                gui_context.output(|output| {
                    if let Some(url) = &output.open_url {
                        web_sys::window()
                            .unwrap()
                            .open_with_url_and_target(&url.url, "_blank")
                            .unwrap();
                    }
                });

See also https://github.com/emilk/egui/issues/2974.