Repository navigation
Description
Version/Branch of Dear ImGui:
Version 1.92.6, Branch: docking (master/docking/etc.)
Back-ends:
imgui_impl_SDL3.cpp + imgui_impl_metal.cpp (don't think backends have an impact here)
Compiler, OS:
macOS + Apple clang version 17.0.0 (clang-1700.3.19.1
Full config/build information:
Dear ImGui 1.92.6 (19261)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __APPLE__
define: __GNUC__=4
define: __clang_version__=17.0.0 (clang-1700.3.19.1)
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl3 (3.4.2; 3.4.2)
io.BackendRendererName: imgui_impl_metal
io.ConfigFlags: 0x00000483
NavEnableKeyboard
NavEnableGamepad
DockingEnable
ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigMacOSXBehaviors
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00002C1E
HasMouseCursors
HasSetMousePos
PlatformHasViewports
HasParentViewport
RendererHasVtxOffset
RendererHasTextures
RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1280.00,800.00
io.DisplayFramebufferScale: 2.00,2.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.00Details:
We've noticed a rather strange behavior when a multiline InputText (ImGui::InputTextMultiline) gets deactivate by activating (clicking) an input that was defined earlier in the frame, causes the changes to be lost when used in combination with IsItemDeactivatedAfterEdit.
I've made some minor changes to imgui_demo.cpp to replicate the issue.
imgui-imgui_demo.patch
The changes are:
- use imgui_stdlib to work with std::string as buffer for InputTextMultiline
- replaced the InputText widgets in the 'Filtered Text Input' section, to make replication our use-case more easily
- only apply persistent change to static stored string via IsItemDeactivatedAfterEdit() check
- updated makefile to include imgui_stdlib
I'm not 100% confident, but when the InputTextMultiline widget gets deactivated, its own internal IsItemDeactivatedAfterEdit() check fails and the apply_new_text variable isn't set to g.InputTextDeactivatedState.TextA.Data, causing the IsItemDeactivatedAfterEdit() on the outside to trigger, but the value contains the unmodified string because the result isn't copied to the user buffer.
On why sItemDeactivatedAfterEdit() returns false, it seems that IsItemDeactivated() returns false because g.DeactivatedItemData.ID == g.LastItemData.ID is false. Some more digging leads me to believe that this is false because ImGui::InputTextEx adds a Dummy widget when it is set to multline, which changes g.LastItemData.ID (but I must admit it's all rather difficult to follow for me).
Using Ctrl+Enter to apply the text changes does work as expected, or deactivating without activating some other item, does seem to work as expected. The issue only occurs by deactivating the multiline InputText by activating another item.
So the 'position' in the draworder of the activated item matters to trigger this bug or not.
I've made some screencaptures to demonstrate the problem. But if more information is needed I will gladly provide it.
Screenshots/Video:
Screen.Recording.2026-03-18.at.15.30.04.mov
Minimal, Complete and Verifiable Example code:
// Here's some code anyone can copy and paste to reproduce your issue
// when deactivating InputTextMultiline 'default' by clicking on InputTextMultiline 'decimar' will cause IsItemDeactivatedAfterEdit() true, and buff1 will what the user typed.
static std::string sbuff1 = "";
std::string buff1 = sbuff1;
ImGui::InputTextMultiline("default", &buff1);
if (ImGui::IsItemDeactivatedAfterEdit())
sbuff1 = buff1; // Copy back modified buffer to our std::string after InputText() is done with it.
// when deactivating InputTextMultiline 'decimal' by clicking on InputTextMultiline 'default' will cause IsItemDeactivatedAfterEdit() true, but buff2 will be "" instead of what the user typed.
static std::string sbuff2 = "";
std::string buff2 = sbuff2;
ImGui::InputTextMultiline("decimal", &buff2, ImVec2(0, 0));
if (ImGui::IsItemDeactivatedAfterEdit())
sbuff2 = buff2;
Activity
ocornut commentedon Mar 18, 2026
I'm currently working on #701 since its absence is at the root of all those problems, but will investigate this separately.
Also note that using Tab/Shift+Tab leads to the same issue.
ocornut commentedon Mar 18, 2026
To clarify, this is not related to the use of std::string or imgui_stdlib.h, but rather related to the fact that no underlying buffer is preserved by the user and InputText() to user buffer write-back is not applied during the
IsItemDeactivatedAfterEdit()frame.geertbleyen commentedon Mar 19, 2026
I didn't intend to suggest using std::string or imgui_stdlib was contributing to the observed issue. It was just easier to create a condensed example of the issue as I don't copy char buffers :).
But thanks for already looking into it
TestSuite: amend "widgets_status_inputtext" to include InputTextMulti…
ocornut commentedon Mar 19, 2026
Linking to #8915, #8273 for related issues previously fixed for
InputText()without multi-line.I suspect this idiom of not persisting the underlying never really worked for multi-line (for various reasons). I'm working on it.
InputTextMultiline: avoid going through reactivation path and InputTe…
InputTextMultiline: fixed losing revert value when activating scrollb…
InputTextMultiline: fixed an issue where edit buffer wouldn't be reap…
TestSuite: amend "widgets_status_inputtext", "widgets_inputtext_temp_…
ocornut commentedon Mar 20, 2026
I have pushed 2d95715 + 04dfcd8 + 2315b9f related to this, the last one being actual fix for this issue but two previous commits are required for it for work.
ocornut/imgui_test_engine@73e2906
ocornut/imgui_test_engine@58d95ac
geertbleyen commentedon Mar 20, 2026
Awesome, thanks! This proved to be well outside my level of understanding of the inner workings of imgui :).
ocornut commentedon Mar 20, 2026
InputTextMultiline()is doing a few odd stuff which are really not pretty to look at.I've been considering removing the child window at some point, it might simplify a few things.
Added ImGuiItemFlags_LiveEdit flag, and much-awaited support for disa…
Split ImGuiItemFlags_LiveEdit into ImGuiItemFlags_LiveEditText, ImGui…