From a286c7b1a7d107794f54a285804707ec98817f19 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Tue, 11 Oct 2022 22:12:01 +0200 Subject: [PATCH] Text input overwrite max size template The TextInput would not allow another key press if the template that is going to be overwritten is over the over the buffer size. This change clears any default text, before checking the length of entered input. --- applications/gui/modules/text_input.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/applications/gui/modules/text_input.c b/applications/gui/modules/text_input.c index 26f74e7ac..9dff957f7 100644 --- a/applications/gui/modules/text_input.c +++ b/applications/gui/modules/text_input.c @@ -318,15 +318,17 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, b } } else if(selected == BACKSPACE_KEY) { text_input_backspace_cb(model); - } else if(text_length < (model->text_buffer_size - 1)) { + } else { if(model->clear_default_text) { text_length = 0; } - if(text_length == 0 && char_is_lowercase(selected)) { - selected = char_to_uppercase(selected); + if(text_length < (model->text_buffer_size - 1)) { + if(text_length == 0 && char_is_lowercase(selected)) { + selected = char_to_uppercase(selected); + } + model->text_buffer[text_length] = selected; + model->text_buffer[text_length + 1] = 0; } - model->text_buffer[text_length] = selected; - model->text_buffer[text_length + 1] = 0; } model->clear_default_text = false; }