BodyAddChild PopupContext needs to happen immediately upon triggering it.

PiperOrigin-RevId: 881955422
Change-Id: I03675431d78c93550ff2ad6d562daf1a0e3d0d08
This commit is contained in:
Haroon Qureshi
2026-03-11 05:19:28 -07:00
committed by Copybara-Service
parent acf7f030a6
commit df02fe4bc0
+17 -16
View File
@@ -93,28 +93,29 @@ static void AddEditorButtons(mjsElement* element, mjsElement** selected_element,
if (ImGui::SmallButton(ICON_FA_PLUS)) {
ImGui::OpenPopupOnItemClick("BodyAddChild", 0);
}
if (ImGui::BeginPopupContextItem("BodyAddChild")) {
mjsBody* body = mjs_asBody(element);
auto option = [&](const char* label, mjtObj type) {
if (ImGui::Selectable(label)) {
*selected_element = editor.AddBodyElement(body, type);
}
};
option("Camera", mjOBJ_CAMERA);
option("Frame", mjOBJ_FRAME);
option("Geom", mjOBJ_GEOM);
option("Joint", mjOBJ_JOINT);
option("Light", mjOBJ_LIGHT);
option("Site", mjOBJ_SITE);
ImGui::EndPopup();
}
ImGui::SameLine();
}
if (ImGui::SmallButton(ICON_FA_TRASH_CAN)) {
editor.DeleteActiveElement();
*selected_element = nullptr;
}
if (ImGui::BeginPopupContextItem("BodyAddChild")) {
mjsBody* body = mjs_asBody(element);
auto option = [&](const char* label, mjtObj type) {
if (ImGui::Selectable(label)) {
*selected_element = editor.AddBodyElement(body, type);
}
};
option("Camera", mjOBJ_CAMERA);
option("Frame", mjOBJ_FRAME);
option("Geom", mjOBJ_GEOM);
option("Joint", mjOBJ_JOINT);
option("Light", mjOBJ_LIGHT);
option("Site", mjOBJ_SITE);
ImGui::EndPopup();
}
}
static void SelectableElement(mjsElement* element,