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/check.c') diff --git a/src/tk/check.c b/src/tk/check.c index 898a21e..b26f7d7 100644 --- a/src/tk/check.c +++ b/src/tk/check.c @@ -34,6 +34,7 @@ struct mftk_check { struct mftk_widget *label; int steals_focus; int (*action)(void *, int); + int (*submit)(void *); void *user_data; }; @@ -101,12 +102,13 @@ _mftk_check_key_event(struct mftk_widget *w, SDL_Event *e) case SDL_KEYDOWN: switch (e->key.keysym.sym) { case SDLK_SPACE: - case SDLK_RETURN: c->state = !c->state; if (c->action == NULL) { return 0; } return c->action(c->user_data,c->state); + case SDLK_RETURN: + return c->submit(c->user_data); default: break; } @@ -266,8 +268,8 @@ struct mftk_widget * mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color, SDL_Color *mark_color, int state, int label_padding, TTF_Font *font, const char *text, SDL_Color *text_color, - int (*action)(void *, int), void *user_data, - SDL_Renderer *renderer) + int (*action)(void *, int), int (*submit)(void *), + void *user_data, SDL_Renderer *renderer) { struct mftk_widget *w; struct mftk_check *c; @@ -291,6 +293,7 @@ mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color, c->label_padding = label_padding; c->steals_focus = SDL_TRUE; c->action = action; + c->submit = submit; c->user_data = user_data; return w; -- cgit v0.9.1