Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryEditor does not allow editing #36

Closed
learn-more opened this issue Feb 21, 2024 · 5 comments
Closed

MemoryEditor does not allow editing #36

learn-more opened this issue Feb 21, 2024 · 5 comments
Labels

Comments

@learn-more
Copy link

TLDR: I can't get the memory editor to 'edit' anything, and I am unsure how to debug this.

Observed issue: When selecting a byte (both in the hex or ascii columns) the byte is briefly selected, after which the selection seems to get lost again?
See screen recording:

example_glfw_vulkan_2024-02-21_22-20-34.mp4

This occurs in a (minimally) edited branch of Dear ImGui, details:

Version: v1.90.3-docking
Backend: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler/OS: Win10 22H2 + MSVC 2022 (17.7.4)
Full config/build information:

Dear ImGui 1.90.3 (19030)
--------------------------------
sizeof(size_t): 4, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: IMGUI_DISABLE_OBSOLETE_KEYIO
define: _WIN32
define: _MSC_VER=1900
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_vulkan
io.ConfigFlags: 0x00000443
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000140E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

To reproduce:

  • Download imgui_memory_editor.h from ea49dd3 and drop it next to imgui.h
  • Enable the attached patch
  • Open Another Window
  • Click on a byte

Patch :

$ git diff
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index c852e5f4d..47dd787c6 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -16,6 +16,7 @@
 #include "imgui.h"
 #include "imgui_impl_glfw.h"
 #include "imgui_impl_vulkan.h"
+#include "imgui_memory_editor.h"
 #include <stdio.h>          // printf, fprintf
 #include <stdlib.h>         // abort
 #define GLFW_INCLUDE_NONE
@@ -539,6 +540,9 @@ int main(int, char**)
             ImGui::Text("Hello from another window!");
             if (ImGui::Button("Close Me"))
                 show_another_window = false;
+            static MemoryEditor edit;
+            static unsigned char data[100];
+            edit.DrawContents(data, sizeof data);
             ImGui::End();
         }
@learn-more learn-more changed the title MemoryEditor does not allow editing anymore MemoryEditor does not allow editing Feb 21, 2024
@ocornut ocornut added the bug label Feb 22, 2024
@ocornut
Copy link
Owner

ocornut commented Feb 22, 2024

Indeed there was a bug.

In "Debug Log" I could see active id is being taken and cleared:
image

With io.ConfigDebugIsDebuggerPresent = true I can hover the value and break on the item:
image

And notice the window itself seems to be taking ActiveID, not the InputText().

Then I followed the trail of calling SetKeyboardFocusHere() -> InputText() and stepped into it, into ItemAdd()->NavProcessItem().
Recalled the implementation of SetKeyboardFocusHere() changed with better tabbing support in 1.89.4, and understood the issue in NavProcessItem():

// This is the code that is relied on for `SetKeyboardFocusHere()`.
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0 && (window->Flags & ImGuiWindowFlags_NoNavInputs) == 0)
{

Memory Editor uses ImGuiWindowFlags_NoNavInputs (via ImGuiWindowFlags_NoNav)

In other word, main lib broke SetKeyboardFocusHere() for windows using ImGuiWindowFlags_NoNavInputs.
I will work on a fix.

@ocornut
Copy link
Owner

ocornut commented Feb 22, 2024

Bug was introduced on February 8 with ocornut/imgui@3a07846

@ocornut
Copy link
Owner

ocornut commented Feb 22, 2024

This is fixed in main line by ocornut/imgui@13d91ff
I will make a release tonight or tomorrow with this.
Thank you for reporting!

@ocornut ocornut closed this as completed Feb 22, 2024
@ocornut
Copy link
Owner

ocornut commented Feb 22, 2024

That'll teach me for not always running tests locally, as soon as I ran them I realized the typo and fixed it: ocornut/imgui@f5be905

@learn-more
Copy link
Author

Thanks for the detailed explanation and the fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants