From 99552420a259076e6a622ec3f9a1a1be14853198 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 25 Oct 2021 17:13:49 +0200 Subject: [PATCH] InputText: triple-click avoid scroll + include end of line character. (#2244) --- imgui_widgets.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 71fca7342..784e1fc38 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4205,8 +4205,16 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ else { // Triple-click: Select line + const bool is_eol = ImStb::STB_TEXTEDIT_GETCHAR(state, state->Stb.cursor) == '\n'; state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART); state->OnKeyPressed(STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT); + state->OnKeyPressed(STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT); + if (!is_eol && is_multiline) + { + ImSwap(state->Stb.select_start, state->Stb.select_end); + state->Stb.cursor = state->Stb.select_end; + } + state->CursorFollow = false; } state->CursorAnimReset(); }