diff options
Diffstat (limited to 'src/tk/text.c')
-rw-r--r-- | src/tk/text.c | 7 |
1 files changed, 6 insertions, 1 deletions
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)); |