-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Description
Version/Branch of Dear ImGui:
Version 1.91.6, Branch: docking
Back-ends:
imgui_impl_opengl3.cpp + imgui_impl_sdl2.cpp
Compiler, OS:
Linux + gcc
Full config/build information:
Dear ImGui 1.91.6 (19160)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: __linux__
define: __GNUC__=14
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl2
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000481
NavEnableKeyboard
DockingEnable
ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
HasMouseCursors
HasSetMousePos
PlatformHasViewports
HasMouseHoveredViewport
RendererHasVtxOffset
RendererHasViewports
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 512,256
io.DisplaySize: 1280.00,960.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
Details:
The ImGui::InputText() function is behaving unexpected (to me). It might be a bug.
I'm passing the flags ImGuiInputTextFlags_EnterReturnsTrue and ImGuiInputTextFlags_EscapeClearsAll to ImGui::InputTextWithHint() (actually I'm using the overload in imgui_stdlib which operates on a std::string, though I checked the code and I don't believe that's relevant). Because I'm passing EnterReturnsTrue (I need to know when the Enter key was pressed) the return-value no longer signals when some edit was made. Therefor I'm also passing ImGuiInputTextFlags_CallbackEdit and a custom callback function.
My expectation was that this callback would trigger on all edits. That's mostly true, except when ESC is pressed to clear the input. I checked that without EnterReturnsTrue, the function does return true on ESC (so CallbackEdit is not a 100% replacement for this return value).
Some background info:
I'm using this to implement a console interface. I'm calling ImGui::InputTextWithHint() with ImGui::PushStyleColor(ImGuiCol_Text, 0) to disable drawing. Soon after I do draw the text myself with custom syntax highlighting (and with some hacks using imgui_internal.h to also draw the cursor). Because syntax highlighting involves non-trivial parsing, I prefer to not have to do that on every frame. Therefor I'd like to know if some edit was made. I was hoping to use ImGuiInputTextFlags_CallbackEdit for that.
The workaround I'm using now is: make a copy of the string before calling InputText() and then check if the string was changed. This works, and it's not super expensive, but it would be nice if this can be avoided. (But it's fine for me to give this issue lower priority).
Thanks.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response