Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to open webpages through imgui widgets ??? #5510

Closed
svkvarun43 opened this issue Jul 27, 2022 · 2 comments
Closed

How to open webpages through imgui widgets ??? #5510

svkvarun43 opened this issue Jul 27, 2022 · 2 comments

Comments

@svkvarun43
Copy link

Version/Branch of Dear ImGui:

Version: 1.88
Branch: master

My Issue/Question:

Hi, I am interested to know if we can add hyperlinks (url) to open up using Imgui

eg:

Press button widget -> open up a webpage (for example google)

Sorry that i cannot provide any information, but if there is an API to get this feature, please do share

@ocornut
Copy link
Owner

ocornut commented Jul 27, 2022

Opening a webpage or external applications is out of the scope of Dear ImGui.

If I type "how to open a webpage in imgui" on google I stumble on this question:
https://stackoverflow.com/questions/71712920/how-to-open-a-webpage-in-imgui

Which I have answered myself, and copying answer here:


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
}

@ocornut ocornut closed this as completed Jul 27, 2022
@ocornut
Copy link
Owner

ocornut commented Jul 2, 2024

This was formalized today in a portable manner with the io.PlatformOpenInShellFn handler and new TextLinkOpenURL() widget, see #7660 (comment)
hyperlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants