Update KeyPressed reference in imgui_memory_editor

This commit is contained in:
scawful
2024-11-15 23:46:44 -05:00
parent 1e330f4a72
commit c17a880830

View File

@@ -253,13 +253,23 @@ struct MemoryEditor
size_t preview_data_type_size = OptShowDataPreview ? DataTypeGetSize(PreviewDataType) : 0; size_t preview_data_type_size = OptShowDataPreview ? DataTypeGetSize(PreviewDataType) : 0;
size_t data_editing_addr_next = (size_t)-1; size_t data_editing_addr_next = (size_t)-1;
if (DataEditingAddr != (size_t)-1) if (DataEditingAddr != (size_t)-1) {
{ // Move cursor but only apply on next frame so scrolling with be
// Move cursor but only apply on next frame so scrolling with be synchronized (because currently we can't change the scrolling while the window is being rendered) // synchronized (because currently we can't change the scrolling while the
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)) && (ptrdiff_t)DataEditingAddr >= (ptrdiff_t)Cols) { data_editing_addr_next = DataEditingAddr - Cols; } // window is being rendered)
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && (ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - Cols) { data_editing_addr_next = DataEditingAddr + Cols; } if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) &&
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && (ptrdiff_t)DataEditingAddr > (ptrdiff_t)0) { data_editing_addr_next = DataEditingAddr - 1; } (ptrdiff_t)DataEditingAddr >= (ptrdiff_t)Cols) {
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)) && (ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - 1) { data_editing_addr_next = DataEditingAddr + 1; } data_editing_addr_next = DataEditingAddr - Cols;
} else if (ImGui::IsKeyPressed(ImGuiKey_DownArrow) &&
(ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - Cols) {
data_editing_addr_next = DataEditingAddr + Cols;
} else if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) &&
(ptrdiff_t)DataEditingAddr > (ptrdiff_t)0) {
data_editing_addr_next = DataEditingAddr - 1;
} else if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) &&
(ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - 1) {
data_editing_addr_next = DataEditingAddr + 1;
}
} }
// Draw vertical separator // Draw vertical separator