InputText, InputInt, InputFloat: fixed an issue where using Escape to revert would not write back the reverted value. (#8915, #8273)

Revealed by 00f12b9a0
Regression test: "widgets_inputtext_temp_buffer_2"
This commit is contained in:
ocornut
2025-09-04 13:13:58 +02:00
parent b7cb3d93a4
commit 605a751571
3 changed files with 7 additions and 3 deletions

View File

@@ -5058,14 +5058,14 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
{
// Clear input
IM_ASSERT(buf[0] != 0);
IM_ASSERT(buf[0] != 0); // FIXME: use TextA here?
apply_new_text = "";
apply_new_text_length = 0;
value_changed = true;
IMSTB_TEXTEDIT_CHARTYPE empty_string;
stb_textedit_replace(state, state->Stb, &empty_string, 0);
}
else if (strcmp(buf, state->TextToRevertTo.Data) != 0)
else if (strcmp(state->TextA.Data, state->TextToRevertTo.Data) != 0)
{
apply_new_text = state->TextToRevertTo.Data;
apply_new_text_length = state->TextToRevertTo.Size - 1;