@@ -21,7 +21,7 @@ typedef struct {
2121 size_t text_buffer_size ;
2222 bool clear_default_text ;
2323
24- IntInputCallback input_callback ;
24+ IntInputCallback callback ;
2525 //IntChangedCallback changed_callback;
2626 void * callback_context ;
2727
@@ -263,13 +263,14 @@ UNUSED(text_length);
263263 if (model -> clear_default_text ) {
264264 text_length = 0 ;
265265 }
266- if (text_length < (model -> text_buffer_size - 1 )) {
266+ // if(text_length < (model->text_buffer_size - 1)) {
267267 //model->text_buffer[text_length] = selected;
268268 //model->text_buffer[text_length + 1] = 0;
269- //FURI_LOG_D("INT_INPUT", model->text_buffer);
270- FURI_LOG_D ("INT_INPUT" , "%u" , text_length );
271- FURI_LOG_D ("INT_INPUT" , "%u" , model -> text_buffer_size );
272- }
269+ FURI_LOG_D ("INT_INPUT" , model -> text_buffer );
270+ //FURI_LOG_D("INT_INPUT", "%u", text_length);
271+ //FURI_LOG_D("INT_INPUT", "%u", model->text_buffer_size);
272+ FURI_LOG_D ("INT_INPUT" , "%d" , selected );
273+ //}
273274 }
274275 model -> clear_default_text = false;
275276}
@@ -402,6 +403,7 @@ static bool int_input_view_input_callback(InputEvent* event, void* context) {
402403 int_input_handle_ok (model );
403404 break ;
404405 default :
406+ consumed = false;
405407 break ;
406408 }
407409 }
@@ -412,15 +414,26 @@ static bool int_input_view_input_callback(InputEvent* event, void* context) {
412414 return consumed ;
413415}
414416
415- /** Reset all input-related data in model
416- *
417- * @param model The model
418- */
419- static void int_input_reset_model_input_data (IntInputModel * model ) {
420- model -> selected_row = 0 ;
421- model -> selected_column = 0 ;
417+ void int_input_reset (IntInput * int_input ) {
418+ FURI_LOG_D ("INT_INPUT" , "Resetting Model" );
419+ furi_assert (int_input );
420+ with_view_model (
421+ int_input -> view ,
422+ IntInputModel * model ,
423+ {
424+ model -> header = "" ;
425+ model -> selected_row = 0 ;
426+ model -> selected_column = 0 ;
427+ model -> clear_default_text = false;
428+ model -> text_buffer = "" ;
429+ model -> text_buffer_size = 0 ;
430+ model -> callback = NULL ;
431+ model -> callback_context = NULL ;
432+ },
433+ true);
422434}
423435
436+
424437IntInput * int_input_alloc () {
425438 IntInput * int_input = malloc (sizeof (IntInput ));
426439 int_input -> view = view_alloc ();
@@ -429,17 +442,7 @@ IntInput* int_input_alloc() {
429442 view_set_draw_callback (int_input -> view , int_input_view_draw_callback );
430443 view_set_input_callback (int_input -> view , int_input_view_input_callback );
431444
432- with_view_model (
433- int_input -> view ,
434- IntInputModel * model ,
435- {
436- model -> header = "" ;
437- model -> input_callback = NULL ;
438- // model->changed_callback = NULL;
439- model -> callback_context = NULL ;
440- int_input_reset_model_input_data (model );
441- },
442- true);
445+ int_input_reset (int_input );
443446
444447 return int_input ;
445448}
@@ -457,19 +460,16 @@ View* int_input_get_view(IntInput* int_input) {
457460
458461void int_input_set_result_callback (
459462 IntInput * int_input ,
460- IntInputCallback input_callback ,
461- //IntChangedCallback changed_callback,
463+ IntInputCallback callback ,
462464 void * callback_context ,
463465 char * text_buffer ,
464466 size_t text_buffer_size ,
465467 bool clear_default_text ) {
466- //UNUSED(changed_callback);
467468 with_view_model (
468469 int_input -> view ,
469470 IntInputModel * model ,
470471 {
471- int_input_reset_model_input_data (model );
472- model -> input_callback = input_callback ;
472+ model -> callback = callback ;
473473 model -> callback_context = callback_context ;
474474 model -> text_buffer = text_buffer ;
475475 model -> text_buffer_size = text_buffer_size ;
0 commit comments