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/radio.c') diff --git a/src/tk/radio.c b/src/tk/radio.c index 99e2b8b..79271ee 100644 --- a/src/tk/radio.c +++ b/src/tk/radio.c @@ -37,6 +37,7 @@ struct mftk_radio { int state; int options; int (*action)(void *, int); + int (*submit)(void *); void *user_data; }; @@ -117,6 +118,8 @@ _mftk_radio_key_event(struct mftk_widget *w, SDL_Event *e) return 0; } return r->action(r->user_data,r->state); + case SDLK_RETURN: + return r->submit(r->user_data); default: break; } @@ -168,8 +171,9 @@ struct mftk_widget * mftk_radio_new(int butn_width, int butn_padding, SDL_Color *butn_color, SDL_Color *mark_color, int label_padding, int item_padding, TTF_Font *font, SDL_Color *text_color, - int (*action)(void *, int), void *user_data, - SDL_Renderer *renderer, int state, int options, ...) + int (*action)(void *, int), int (*submit)(void *), + void *user_data, SDL_Renderer *renderer, int state, int options, + ...) { struct mftk_widget *w; struct mftk_radio *r; @@ -201,7 +205,7 @@ mftk_radio_new(int butn_width, int butn_padding, SDL_Color *butn_color, r->children[i] = mftk_check_new(butn_width, butn_padding, butn_color, mark_color, (i == state), label_padding, font, va_arg(ap, const char *), - text_color, &_mftk_radio_state_change, + text_color, &_mftk_radio_state_change, submit, &r->states[i], renderer); if (r->children[i] == NULL) { for (; i >= 0; --i) { @@ -234,6 +238,7 @@ mftk_radio_new(int butn_width, int butn_padding, SDL_Color *butn_color, r->state = state; r->options = options; r->action = action; + r->submit = submit; r->user_data = user_data; return w; -- cgit v0.9.1