如何在 ImGui 中打开网页

sti*_*kie 1 imgui

我到处都找过了,但似乎找不到解决我的问题的方法。我想知道如何使用 imgui 打开弹出窗口并使用“https://google.com”等网站打开 chrome 窗口。我认为 ImGui::OpenPopup 可能会起作用,但后来我查看了该函数,然后在谷歌上查看,似乎它不起作用。当您单击一个按钮时,它会重定向到计算机上的一个窗口,就像您单击不和谐中的链接时,它会在您的计算机上打开一个谷歌选项卡。

我认为它可能看起来有点像这样

void GUI::renderAboutMenu() noexcept
{
    if (ImGui::MenuItem("My Discord"))
        openWebsite("https://discord.gg/myinvitecode");
    if (ImGui::MenuItem("My Patreon"))
        openWebsite("https://patreon.com/myinvitecode");

}
Run Code Online (Sandbox Code Playgroud)

Oma*_*mar 6

这实际上并不是一个亲爱的 imgui 问题,更多的是关于如何使用操作系统 API 来执行此操作。

类似的东西会起作用:

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
}
Run Code Online (Sandbox Code Playgroud)