You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to put a button in the same line as the header of the tree window (eg code below), and I am having issues getting the button to activate reliably. By that I mean; it either needs a lot of clicks to trigger, or it only opens when the tree window is open.
Here's a minimal example code of what I'm doing:
ImGui::AlignTextToFramePadding();
bool treeopen = ImGui::TreeNode("TreeTest");
ImGui::SameLine();
if (ImGui::Button("+")) ImGui::OpenPopup("ElementList");
if (ImGui::IsItemHovered()) ImGui::SetTooltip("new element");
if (ImGui::BeginPopup("ElementList")) {
ImGui::MenuItem("element 1");
ImGui::EndPopup();
}
if (treeopen)
ImGui::TreePop();
I tried this instead:
bool treeopen = ImGui::TreeNodeEx("TreeTest", ImGuiButtonFlags_AllowItemOverlap);
But it actually made opening the tree harder through the arrow.
What's the preferred setup to make this work?
The text was updated successfully, but these errors were encountered:
ImGui::AlignTextToFramePadding();
bool treeopen = ImGui::TreeNodeEx("TreeTest", ImGuiTreeNodeFlags_AllowItemOverlap);
ImGui::SameLine();
if (ImGui::Button("+")) ImGui::OpenPopup("ElementList");
if (ImGui::IsItemHovered()) ImGui::SetTooltip("new element");
if (ImGui::BeginPopup("ElementList"))
{
ImGui::MenuItem("element 1");
ImGui::MenuItem("element 2");
ImGui::EndPopup();
}
if (treeopen)
{
ImGui::Text("Tree contents");
ImGui::TreePop();
}
You said:
"I tried this instead:
bool treeopen = ImGui::TreeNodeEx("TreeTest", ImGuiButtonFlags_AllowItemOverlap);"
I think you meant ImGuiTreeNodeFlags_AllowItemOverlap and NOT ImGuiButtonFlags_AllowItemOverlap here.
You may otherwise have another issue in your real app code where maybe the identifier of the + buttons are conflicting with each others (if you don't use PushID/PopID).
Hi,
I'm trying to put a button in the same line as the header of the tree window (eg code below), and I am having issues getting the button to activate reliably. By that I mean; it either needs a lot of clicks to trigger, or it only opens when the tree window is open.
Here's a minimal example code of what I'm doing:
ImGui::AlignTextToFramePadding();
bool treeopen = ImGui::TreeNode("TreeTest");
ImGui::SameLine();
if (ImGui::Button("+")) ImGui::OpenPopup("ElementList");
if (ImGui::IsItemHovered()) ImGui::SetTooltip("new element");
if (ImGui::BeginPopup("ElementList")) {
ImGui::MenuItem("element 1");
ImGui::EndPopup();
}
if (treeopen)
ImGui::TreePop();
I tried this instead:
bool treeopen = ImGui::TreeNodeEx("TreeTest", ImGuiButtonFlags_AllowItemOverlap);
But it actually made opening the tree harder through the arrow.
What's the preferred setup to make this work?
The text was updated successfully, but these errors were encountered: