I want to create an ImGui button, when I click on this button, I want it to redirect to a url, that is, to the browser, how can I do that? can you help me please?
I want to create an ImGui button, when I click on this button, I want it to redirect to a url, that is, to the browser, how can I do that? can you help me please?
Creating a button:
#[imgui(
button(size = "button_size",
label = "Click me!",
catch ="click"),
separator,
display(label = "Clicks"),
)]
count: i32, }
const fn button_size() -> (f32, f32){
(100.0, 20.0)
}
However, opening a webpage is a bit harder since it depends on the api of the os that you're using. Doing that for windows and mac would look like this:
void OsOpenInShell(const char* path) {
#ifdef _WIN32
// Note: executable path must use backslashes!
::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT);
#else
#if __APPLE__ const char* open_executable = "open";
#else
const char* open_executable = "xdg
open";
#endif char command[256];
snprintf(command, 256, "%s \"%s\"",
open_executable, path);
system(command);
#endif
Then you could put the previous code inside this:
let events = ui.imgui_ext(&mut buttons);
if events.click {
*insert code*
}