mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Pattern data section context menu not opening correctly
This commit is contained in:
@@ -118,6 +118,7 @@ namespace hex::plugin::builtin {
|
||||
} else {
|
||||
static i32 selectedSection = -1;
|
||||
for (auto &[id, drawer] : *m_patternDrawer) {
|
||||
ImGui::PushID(id + 1);
|
||||
drawer->enablePatternEditing(ImHexApi::Provider::get()->isWritable());
|
||||
|
||||
// If the runtime has finished evaluating, draw the patterns
|
||||
@@ -126,31 +127,34 @@ namespace hex::plugin::builtin {
|
||||
if (id != 0 && !sections.contains(id))
|
||||
continue;
|
||||
|
||||
if (ImGui::BeginTabItem(id == 0 ? "hex.builtin.view.pattern_data.section.main"_lang : sections.at(id).name.c_str())) {
|
||||
const bool open = ImGui::BeginTabItem(id == 0 ? "hex.builtin.view.pattern_data.section.main"_lang : sections.at(id).name.c_str());
|
||||
const bool hovered = ImGui::IsItemHovered();
|
||||
if (open) {
|
||||
drawer->draw(runtime.getPatterns(id), &runtime, height);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (id != 0) {
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Right) && ImGui::IsItemHovered() && !ImGui::IsMouseDragging(ImGuiMouseButton_Right)) {
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Right) && hovered && !ImGui::IsMouseDragging(ImGuiMouseButton_Right)) {
|
||||
ImGui::OpenPopup("##PatternDataContextMenu");
|
||||
selectedSection = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("##PatternDataContextMenu")) {
|
||||
if (ImGui::MenuItemEx("hex.builtin.view.pattern_data.section.view_raw"_lang, ICON_VS_OPEN_PREVIEW)) {
|
||||
if (TRY_LOCK(ContentRegistry::PatternLanguage::getRuntimeLock())) {
|
||||
const auto §ions = runtime.getSections();
|
||||
if (auto it = sections.find(selectedSection); it != sections.end()) {
|
||||
const auto &[id, section] = *it;
|
||||
ImHexApi::Provider::add<prv::MemoryProvider>(section.data, section.name);
|
||||
if (ImGui::BeginPopup("##PatternDataContextMenu")) {
|
||||
if (ImGui::MenuItemEx("hex.builtin.view.pattern_data.section.view_raw"_lang, ICON_VS_OPEN_PREVIEW)) {
|
||||
if (TRY_LOCK(ContentRegistry::PatternLanguage::getRuntimeLock())) {
|
||||
if (auto it = sections.find(selectedSection); it != sections.end()) {
|
||||
const auto &[sectionId, section] = *it;
|
||||
ImHexApi::Provider::add<prv::MemoryProvider>(section.data, section.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user