diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-08-06 00:34:48 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-08-06 00:59:34 (EDT) |
commit | ab7ea3c8367dad3101a250bfe6873753ba1875b1 (patch) | |
tree | c543b82ffc4992291be1bb8026e8cbe24880538d | |
parent | aa8ac0850cb363778577c27b9afc5c2223d7f770 (diff) | |
download | mazefight-ab7ea3c8367dad3101a250bfe6873753ba1875b1.zip mazefight-ab7ea3c8367dad3101a250bfe6873753ba1875b1.tar.gz mazefight-ab7ea3c8367dad3101a250bfe6873753ba1875b1.tar.bz2 |
tk: Make event callbacks optional
-rw-r--r-- | src/tk/button.c | 3 | ||||
-rw-r--r-- | src/tk/check.c | 3 | ||||
-rw-r--r-- | src/tk/radio.c | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/tk/button.c b/src/tk/button.c index ffac9de..57e505a 100644 --- a/src/tk/button.c +++ b/src/tk/button.c @@ -51,6 +51,9 @@ _mftk_button_event(struct mftk_widget *w, SDL_Event *e, switch (e->type) { case SDL_MOUSEBUTTONUP: if (e->button.button == SDL_BUTTON_LEFT) { + if (b->action == NULL) { + return 0; + } return b->action(b->user_data); } break; diff --git a/src/tk/check.c b/src/tk/check.c index 6f70dd0..5c73554 100644 --- a/src/tk/check.c +++ b/src/tk/check.c @@ -82,6 +82,9 @@ _mftk_check_event(struct mftk_widget *w, SDL_Event *e, case SDL_MOUSEBUTTONUP: if (e->button.button == SDL_BUTTON_LEFT) { c->state = !c->state; + if (c->action == NULL) { + return 0; + } return c->action(c->user_data, c->state); } break; diff --git a/src/tk/radio.c b/src/tk/radio.c index 71c9486..27f7d37 100644 --- a/src/tk/radio.c +++ b/src/tk/radio.c @@ -53,6 +53,9 @@ _mftk_radio_state_change(void *user_data, int state) mftk_check_set_state(rs->r->children[rs->r->state], SDL_FALSE); /* Set and announce new state */ rs->r->state = rs->state; + if (rs->r->action == NULL) { + return 0; + } return rs->r->action(rs->r->user_data, rs->r->state); } } |