-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Have a way to handle a event from window title bar? #7369
Comments
After ImGui::Begin("Hello, world!", nullptr, ImGuiWindowFlags_NoCollapse);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
printf("hi\n"); You need to disable collapsing otherwise this would conflict with the double-clicking. I pushed 65dc67f which allows overriding this via the key-ownership mechanism, so if you pull you could use: ImGui::Begin("Hello, world!");
if (ImGui::IsItemHovered())
{
ImGuiID my_id = ImGui::GetID("left-click-interceptor");
ImGui::SetKeyOwner(ImGuiKey_MouseLeft, my_id);
if (ImGui::IsMouseDoubleClicked(0, my_id))
printf("hi\n");
} However, while that answers your question I think both solutions are incorrect as they would likely interact wrongly with docked window. I think you would better use a context-menu for that: ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
if (ImGui::BeginPopupContextItem(nullptr, ImGuiPopupFlags_MouseButtonRight))
{
if (ImGui::MenuItem("Rename..."))
printf("hi\n");
ImGui::EndPopup();
} This will work with docked window. Note that if you rename windows you need to use the ### operator to preserve their unique identifier, so their imgui-side names should be "User Visible Name###Internal Name". Otherwise after you rename dear imgui will think it is a different window. See "Demo->Examples->Manipulating Window Titles" for an example. |
Thank you! It solved my doubt |
Version/Branch of Dear ImGui:
Version 1.90.4, Branch: master
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Windows 10
Full config/build information:
Details:
My Issue/Question:
I'm new in C++ and ImGui, so I'm not finded a exemple to it:
I need to handle a double click event in the window titlebar. My idea was create a way to the user change the title with double click, so the window title would to be a input. But I know that it can be hard to implement, so if I show a modal asking the user a new window name, solve my problem. But I don't know how to add this event for the window title...
Thank you everyone!
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: