From f7f71043ca830d7c5bff9b62f471c33e041ebbc3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 16 Jul 2015 20:46:27 -0600 Subject: [PATCH] InputText: stb_textedit.h tentative fix for End key on multi-line fields (#275) --- stb_textedit.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stb_textedit.h b/stb_textedit.h index 5aa79f02..3972c0f4 100644 --- a/stb_textedit.h +++ b/stb_textedit.h @@ -1,3 +1,6 @@ +// [ImGui] this is a slightly modified version of stb_truetype.h 1.4 +// [ImGui] we made a fix for using the END key on multi-line text edit, see https://github.com/ocornut/imgui/issues/275 + // stb_textedit.h - v1.4 - public domain - Sean Barrett // Development of this library was sponsored by RAD Game Tools // @@ -957,6 +960,8 @@ retry: stb_textedit_move_to_first(state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); state->cursor = find.first_char + find.length; + if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE) + state->cursor--; state->has_preferred_x = 0; break; } @@ -977,6 +982,8 @@ retry: stb_textedit_prep_selection_at_cursor(state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); state->cursor = state->select_end = find.first_char + find.length; + if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE) + state->cursor = state->select_end = state->cursor - 1; state->has_preferred_x = 0; break; }