-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Overlapped InputText doesn't take the focus since 1.89.7 #6690
Comments
Hello Cyril, Thanks for posting a detailed and well researched issue. The workaround to get to the same logic as the previous ImGuiContext& g = *GImGui;
if (g.ActiveId == ImGui::GetItemID())
g.ActiveIdAllowOverlap = true; Because you only need that to be set once to allow the However for this specific logic you are using, technically you could also just call Note that this pattern is analogous to what we are using for CTRL+Clicking into Sliders and Drags. EDIT
Almost but not quite ;) But for future reference here's a version that is pastable directly: {
static bool editing = false;
ImVec2 cursor = ImGui::GetCursorPos();
ImGui::SetNextItemAllowOverlap(); // only in 1.89.7
ImGui::TreeNodeEx("Blah", ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth);
if (!ImGui::IsItemToggledOpen() && ImGui::IsItemClicked() && ImGui::IsMouseDoubleClicked(0))
{
editing = true;
ImGuiContext& g = *GImGui;
//if (g.ActiveId == ImGui::GetItemID())
// g.ActiveIdAllowOverlap = true;
ImGui::SetActiveID(0, NULL);// .ActiveId = 0;
}
if (editing)
{
static char stuff[96] = "Blah";
ImGui::SameLine();
ImGui::SetCursorPos(cursor);
ImGui::InputText("##EditStuff", stuff, 96);
if (ImGui::IsItemDeactivatedAfterEdit())
editing = false;
if (!ImGui::IsItemFocused())
editing = false;
}
} |
Hi Omar, |
Version/Branch of Dear ImGui:
Version: 1.89.8
Branch: master and docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Operating System: macOS/Windows10
My Issue/Question:
Hi,
To edit a tree node value, I used to draw an input text on top of the tree node after double clicking on it.
Screen.Recording.2023-08-05.at.09.22.17.mov
It has been working fine until 1.89.7.
In 1.89.7 and beyond, the InputText doesn’t show up (just one frame)
Screen.Recording.2023-08-05.at.09.41.59.mov
A code example looks like this (this can be pasted in the imgui_demo.cpp) :
I traced the difference to the !ImGui::IsItemFocused() above not behaving the same between 1.89.6 and 1.89.7. In 1.89.7. The InputText is not focused anymore when it is created. I was focused before because the click is “propagated” to the input text which normally takes the focus and allows editing.
After a bit of digging, inside the InputText, ItemHoverable returns false on the ActiveIdAllowOverlap test where it wasn’t in the previous versions.
imgui/imgui.cpp
Line 4059 in d4ddc46
I am not sure if this is a bug, or if my code is incorrect in the first place.
As a workaround I tried removing ImGui::IsItemFocused() but then users have to click again on the InputText to start editing which is not great, the previous behaviour was really convenient, specially focusing on the InputText and start text editing.
Thanks a lot for any help,
Best
Cyril
The text was updated successfully, but these errors were encountered: