C/C++ Link to the site in the Imgui button

Snow

Moderator
Apr 14, 2022
35
4
Here's an example of how to create a button with a link to a website in ImGui:

C++:
ImGui::Button("Click Me!");

if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0))
{
    // Open the link in the default browser
    std::system("start https://ssource.net");
}

In this example, we create a button labeled "Click Me!" using the ImGui::Button function. We then use ImGui::IsItemHovered to check if the user is hovering over the button, and ImGui::IsMouseClicked to check if the user has clicked the button with the left mouse button.

If both conditions are true, we use std::system to open the link in the default browser. You can replace "https://ssource.net" with the URL of the website you want to link to.

Note that this example uses the std::system function, which may not work on all platforms or in all environments. In some cases, you may need to use a platform-specific function or library to open the link in the default browser.
 
Top