Hello guys, good evening.
I’m kinda new to ImGui so this may be a easy question but i’m beating my head up to solve it and ain’t having any progress.
That said, i’d like firstly to contextualize my problem.
I’m writing a program that has a lot of scene objects that are drawn into a hierarchy as TreeNodes and what i’d like to is to to rightClick a node and open a popup with some basic options such as delete, newchildren, change mesh and etc.
Here’s how my code is now, without any treatment in that regard.
P2::drawHierarchyWindow(cg::Scene* node, cg::SceneNode* current, ImGuiTreeNodeFlags flag) {
if (node->root->filhos.size() > 0) {
auto open = ImGui::TreeNodeEx(node, _current == node ? flag | ImGuiTreeNodeFlags_Selected : flag, node->name());
// Update current node.
if (ImGui::IsItemClicked(0))
_current = node;
// Catch the right click
if (ImGui::IsItemClicked(1)) {
// Create a new popup
if (ImGui::OpenPopupOnItemClick())
{
if (ImGui::Selectable("Test"))
{
}
ImGui::EndPopup();
}
}
setDragAndDropTarget(node->root);
if (open) {
for (auto &c : node->root->filhos) {
drawHierarchyWindow(c, _current, flag);
}
ImGui::TreePop();
}
}
else {
// If nodes hasn children
flag |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
ImGui::TreeNodeEx(node, _current == node ? flag | ImGuiTreeNodeFlags_Selected : flag, node->name());
// Update current if node was clicked
if (ImGui::IsItemClicked())
_current = node;
}
}
Well, the code above isn’t working for me as i right click the node and it doesn’t create the pop up.
Doen any of you knows the reason or have any suggestions ?
Thanks in advance, guys and sorry for any lack of education.
I’m new to ImGui and to English as well