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

context menu on node content #40

Open
sphaero opened this issue Dec 14, 2021 · 1 comment
Open

context menu on node content #40

sphaero opened this issue Dec 14, 2021 · 1 comment

Comments

@sphaero
Copy link
Contributor

sphaero commented Dec 14, 2021

Imagine I want to add a context menu on node content. In the sample.cpp:

                // Custom node content may go here
                ImGui::Text("Content of %s", node->Title);
                const char* names[5] = { "Label1", "Label2", "Label3", "Label4", "Label5" };
                for (int n = 0; n < 5; n++)
                {
                    ImGui::Selectable(names[n]);
                    if (ImGui::BeginPopupContextItem()) // <-- use last item id as popup id
                    {
                        ImGui::Text("This a popup for \"%s\"!", names[n]);
                        if (ImGui::Button("Close"))
                            ImGui::CloseCurrentPopup();
                        ImGui::EndPopup();
                    }
                    if (ImGui::IsItemHovered())
                        ImGui::SetTooltip("Right-click to open popup");
                }

This is just pasted from imgui_demo.cpp

This doesn't work. Only the context menu for adding nodes is opened.

@sphaero
Copy link
Contributor Author

sphaero commented Dec 14, 2021

Probably has to do with using Set-/ClearActiveID

Not sure how that's handled correctly

ImNodes/ImNodes.cpp

Lines 451 to 454 in 26c6dbc

if (ImGui::IsMouseDown(0) && !ImGui::IsAnyItemActive() && ImGui::IsItemHovered())
ImGui::SetActiveID(node_item_id, ImGui::GetCurrentWindow());
else if (!ImGui::IsMouseDown(0) && ImGui::IsItemActive())
ImGui::ClearActiveID();

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

1 participant