mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
InputText: stb_textedit.h tentative fix for End key on multi-line fields (#275)
This commit is contained in:
parent
98047b1b65
commit
f7f71043ca
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user