InputText: rename Edited->EditedThisFrame, add EditedBefore. (#701) + Comments + About box clipboard blurb include a comment.

This commit is contained in:
ocornut
2026-04-02 14:30:18 +02:00
parent fc5e421cb9
commit 9e9fdc97bb
4 changed files with 10 additions and 7 deletions
+5 -4
View File
@@ -4184,7 +4184,7 @@ static void STB_TEXTEDIT_DELETECHARS(ImGuiInputTextState* obj, int pos, int n)
char* dst = obj->TextA.Data + pos;
char* src = obj->TextA.Data + pos + n;
memmove(dst, src, obj->TextLen - n - pos + 1);
obj->Edited = true;
obj->EditedBefore = obj->EditedThisFrame = true;
obj->TextLen -= n;
}
@@ -4214,7 +4214,7 @@ static int STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState* obj, int pos, const cha
memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos));
memcpy(text + pos, new_text, (size_t)new_text_len);
obj->Edited = true;
obj->EditedBefore = obj->EditedThisFrame = true;
obj->TextLen += new_text_len;
obj->TextA[obj->TextLen] = '\0';
@@ -4841,6 +4841,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Start edition
state->ID = id;
state->TextLen = buf_len;
state->EditedBefore = false;
if (!is_readonly)
{
state->TextA.resize(buf_size + 1); // we use +1 to make sure that .Data is always pointing to at least an empty string.
@@ -4956,7 +4957,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (g.ActiveId == id)
{
IM_ASSERT(state != NULL);
state->Edited = false;
state->EditedThisFrame = false;
state->BufCapacity = buf_size;
state->Flags = flags;
state->WrapWidth = wrap_width;
@@ -5294,7 +5295,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
event_flag = ImGuiInputTextFlags_CallbackHistory;
event_key = ImGuiKey_DownArrow;
}
else if ((flags & ImGuiInputTextFlags_CallbackEdit) && state->Edited)
else if ((flags & ImGuiInputTextFlags_CallbackEdit) && state->EditedThisFrame)
{
event_flag = ImGuiInputTextFlags_CallbackEdit;
}