From 1b5795c96da069a8aa5231b2df50383ae95e7fe5 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 2 May 2015 12:45:53 +0100 Subject: [PATCH] InputText: fixed incorrect edit state after text buffer is modified by user through callback #206 --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 5f541a0b..fea4010b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6690,7 +6690,8 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT if (callback_data.SelectionEnd != utf8_selection_end) edit_state.StbState.select_end = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); if (callback_data.BufDirty) { - ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), g.TempBuffer, NULL); + edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), g.TempBuffer, NULL); + edit_state.CurLenA = strlen(g.TempBuffer); edit_state.CursorAnimReset(); } }