'How to open a webpage in ImGui
I've looked everywhere, and I can't seem to find the solution to my problem. I am wanting to know how I could use imgui to open a popup window and opening a chrome window with a website like "https://google.com". I thought that ImGui::OpenPopup might work, but then I looked at the function and then on google and it seemed like it wouldn't work. When you click a button and it redirects to a window on your computer, like when you click a link in discord and it opens a google tab on your computer.
I assumed it may look a little like this
void GUI::renderAboutMenu() noexcept
{
if (ImGui::MenuItem("My Discord"))
openWebsite("https://discord.gg/myinvitecode");
if (ImGui::MenuItem("My Patreon"))
openWebsite("https://patreon.com/myinvitecode");
}
Solution 1:[1]
It's not really a dear imgui question, more about how to use your OS API to perform that.
Something like that would work:
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
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omar |
