Fix issue #9001 Make ConfigInputTextEnterKeepActive compatible with IsItemDeactivatedAfterEdit - #9115
Closed
XttZjj wants to merge 1 commit into
Closed
Fix issue #9001 Make ConfigInputTextEnterKeepActive compatible with IsItemDeactivatedAfterEdit#9115XttZjj wants to merge 1 commit into
XttZjj wants to merge 1 commit into
Conversation
ocornut
force-pushed
the
fix-inputtext-deactivate
branch
from
March 11, 2026 19:03
1ae5465 to
34ab325
Compare
Owner
|
Rebased and removed noise from commits. |
ocornut
force-pushed
the
fix-inputtext-deactivate
branch
from
March 11, 2026 19:15
34ab325 to
b04b432
Compare
ocornut
added a commit
to ocornut/imgui_test_engine
that referenced
this pull request
Mar 11, 2026
…", "widgets_inputtext_temp_buffer_2" to exercise io.ConfigInputTextEnterKeepActive. ocornut/imgui#9001 ocornut/imgui#9115
Owner
|
I have merged your fix 03a9946, then reworked it as 5aa7d61 which includes fixing a race condition if e.g. the InputText() gets hidden (stops being submitted) after returning true the deactivation request would linger and trigger later. Thank you! |
ocornut
added a commit
that referenced
this pull request
Mar 11, 2026
Owner
|
For reference a basic test bed for this would be: io.ConfigInputTextEnterKeepActive = true;
static char buf[256] = "hello";
bool ret = ImGui::InputText("Blah", buf, 256, 0);
ImGui::BulletText(
"Return value = %d\n"
"IsItemFocused() = %d\n"
"IsItemHovered() = %d\n"
"IsItemActive() = %d\n"
"IsItemEdited() = %d\n"
"IsItemActivated() = %d\n"
"IsItemDeactivated() = %d\n"
"IsItemDeactivatedAfterEdit() = %d\n"
"IsItemVisible() = %d\n"
"IsItemClicked() = %d\n"
"IsItemToggledOpen() = %d\n",
ret,
ImGui::IsItemFocused(),
ImGui::IsItemHovered(),
ImGui::IsItemActive(),
ImGui::IsItemEdited(),
ImGui::IsItemActivated(),
ImGui::IsItemDeactivated(),
ImGui::IsItemDeactivatedAfterEdit(),
ImGui::IsItemVisible(),
ImGui::IsItemClicked(),
ImGui::IsItemToggledOpen()
);I also confirmed in slow-motion that this doesn't happen to lead to e.g. one frame flickers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9001.
Summary
When
io.ConfigInputTextEnterKeepActiveis enabled, pressing Enter on a single-lineInputTextkeeps the widget active and selects the contents.However, in this mode the item is never considered "deactivated", so
IsItemDeactivatedAfterEdit()never fires and existing undo/finalization logic breaks.Issue
ConfigInputTextEnterKeepActive:IsItemDeactivatedAfterEdit()becomes true for one frame.ConfigInputTextEnterKeepActive:IsItemDeactivatedAfterEdit()is never triggered.IsItemDeactivatedAfterEdit()to finalize edits stops working.Fix
ConfigInputTextEnterKeepActiveis set, I:IsItemDeactivatedAfterEdit()is signaled as usual.InputTextfor the next frame and select its contents.IsItemDeactivatedAfterEdit()while keeping the behavior promised byConfigInputTextEnterKeepActive.Testing
IsItemDeactivatedAfterEdit()never triggered withConfigInputTextEnterKeepActiveenabled.IsItemDeactivatedAfterEdit()is true for one frame when pressing Enter, even with the config flag set.ConfigInputTextEnterKeepActive(unchanged behavior).InputTextexamples.