From d3783c83f614b3beded3d6a5c528005f480524e3 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 07 Aug 2021 14:20:39 -0400 Subject: tk: Add submit callback to check, radio, and text --- (limited to 'src/tk/text.c') diff --git a/src/tk/text.c b/src/tk/text.c index 4a8196d..027da71 100644 --- a/src/tk/text.c +++ b/src/tk/text.c @@ -42,6 +42,7 @@ struct mftk_text { SDL_Color *color; SDL_Texture *texture; int (*action)(void *, const char *); + int (*submit)(void *); void *user_data; }; @@ -123,6 +124,8 @@ _mftk_text_key_event(struct mftk_widget *w, SDL_Event *e) return 0; } return t->action(t->user_data, t->val); + case SDLK_RETURN: + return t->submit(t->user_data); default: break; } @@ -287,7 +290,8 @@ _mftk_text_destroy(struct mftk_widget *w) struct mftk_widget * mftk_text_new(char min_char, char max_char, int len, const char *val, TTF_Font *font, SDL_Color *color, - int (*action)(void *, const char *), void *user_data) + int (*action)(void *, const char *), int (*submit)(void *), + void *user_data) { struct mftk_widget *w; struct mftk_text *t; @@ -306,6 +310,7 @@ mftk_text_new(char min_char, char max_char, int len, const char *val, t->color = color; t->texture = NULL; t->action = action; + t->submit = submit; t->user_data = user_data; t->val = calloc(len + 1, sizeof(*t->val)); -- cgit v0.9.1