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
Back-ends: Custom backend
Compiler: All
Operating System: All
My Issue/Question:
I am using ImGui table to create a grid for my asset browser. I am currently using context menu that opens whenever I click anywhere in the window. Now, I want to add a new context menu when I right click specific item in the table. However, the context menu never gets called. I even tried to use a OpenPopup./BeginPopup instead of BeginPopupContextItem but no luck. Here is a snippet that I am trying out:
if (ImGui::BeginTable("CurrentDir", itemsPerRow,
ImGuiTableFlags_NoPadInnerX)) {
size_t i = 0;
for (; i < mEntries.size(); ++i) {
auto colIndex = i % itemsPerRow;
if (colIndex == 0) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, ItemHeight * 1.0f);
}
ImGui::TableNextColumn();
constauto &entry = mEntries.at(i);
if (ImGui::Selectable(id.c_str(), mSelected == i,
ImGuiSelectableFlags_AllowDoubleClick,
ImVec2(ItemWidth, ItemHeight))) {
// making my item clickable using Selectable
}
if (ImGui::IsItemHovered()) {
// hover logic here
}
// Open popup when right button is clickedif (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
// Note that I reach this condition when right clicking// (checked it with debugger to make sure)ImGui::OpenPopup("AssetBrowserEntryPopup");
}
// Open my popupif (ImGui::BeginPopup("AssetBrowserEntryPopup")) {
if (ImGui::MenuItem("View contents")) {}
ImGui::EndPopup();
}
}
ImGui::EndTable();
}
// Popup menu for non selected itemsif (!ImGui::isPopupOpen("AssetBrowserEntryPopup") && ImGui::BeginPopupContextWindow("AssetBrowserPopup")) {
if (ImGui::MenuItem("Import asset")) {}
ImGui::EndPopup();
}
When hold right click, I see the item entry popup; however, the moment I release the click, context menu overwrites it. Here is a GIF that demonstrated what I mean (ignore the duplicate menu item entries; I'll fix it with IDs but need to get this working first):
What am I doing wrong here? Why does BeginPopupContextWindow overwrite my currently active popup, when I am explicitly calling it only when isPopupOpen is false?
The text was updated successfully, but these errors were encountered:
Popup identifiers are relative to ID stack (see #331) so “ AssetBrowserEntryPopup” doesn’t refer from the same thing in both locations. Use in ImGuiID and equivalent functions from imgui_internal.h, or handle your popups from the same location.
And you should probably also call PushID() inside your loop to make the popup id of each item unique. Using BeginPopupContextItem() i recall use last item ID so it’s not a problem with it.
Popup identifiers are relative to ID stack (see #331) so “ AssetBrowserEntryPopup” doesn’t refer from the same thing in both locations. Use in ImGuiID and equivalent functions from imgui_internal.h, or handle your popups from the same location.
I am using them from the same point right? Since the last item in my id stack is the ImGui::Selectable and I am calling the popup functions right after that.
Version/Branch of Dear ImGui:
Version: latest
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: Custom backend
Compiler: All
Operating System: All
My Issue/Question:
I am using ImGui table to create a grid for my asset browser. I am currently using context menu that opens whenever I click anywhere in the window. Now, I want to add a new context menu when I right click specific item in the table. However, the context menu never gets called. I even tried to use a OpenPopup./BeginPopup instead of
BeginPopupContextItem
but no luck. Here is a snippet that I am trying out:When hold right click, I see the item entry popup; however, the moment I release the click, context menu overwrites it. Here is a GIF that demonstrated what I mean (ignore the duplicate menu item entries; I'll fix it with IDs but need to get this working first):
What am I doing wrong here? Why does
BeginPopupContextWindow
overwrite my currently active popup, when I am explicitly calling it only whenisPopupOpen
is false?The text was updated successfully, but these errors were encountered: