diff options
author | P. J. McDermott <pj@pehjota.net> | 2022-01-27 20:46:26 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2022-01-29 02:11:58 (EST) |
commit | 75fcdd36c96975a5a97b1cd41484cc2498b8c660 (patch) | |
tree | d1ff3b8d68516e6602fd4ca79fa417542d10b8d2 /src/tk | |
parent | f7474176bdd54fc9ea0d929176e9f7275977bcb7 (diff) | |
download | mazefight-75fcdd36c96975a5a97b1cd41484cc2498b8c660.zip mazefight-75fcdd36c96975a5a97b1cd41484cc2498b8c660.tar.gz mazefight-75fcdd36c96975a5a97b1cd41484cc2498b8c660.tar.bz2 |
tk: Add focus indication to radio
Diffstat (limited to 'src/tk')
-rw-r--r-- | src/tk/radio.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/tk/radio.c b/src/tk/radio.c index 9f60bd3..c1facdb 100644 --- a/src/tk/radio.c +++ b/src/tk/radio.c @@ -53,6 +53,9 @@ _mftk_radio_state_change(void *user_data, int state) } else { /* Deselect previous check button */ mftk_check_set_state(rs->r->children[rs->r->state], SDL_FALSE); + /* Update faked focus */ + rs->r->children[rs->r->state]->focused = SDL_FALSE; + rs->r->children[rs->state]->focused = SDL_TRUE; /* Set and announce new state */ rs->r->state = rs->state; if (rs->r->action == NULL) { @@ -73,15 +76,19 @@ _mftk_radio_layout(struct mftk_widget *w) } static void -_mftk_radio_focus(struct mftk_widget *w __attribute__((__unused__))) +_mftk_radio_focus(struct mftk_widget *w) { - /* Nothing to do */ + struct mftk_radio *r = (struct mftk_radio *) w; + + r->children[r->state]->focused = SDL_TRUE; } static void -_mftk_radio_defocus(struct mftk_widget *w __attribute__((__unused__))) +_mftk_radio_defocus(struct mftk_widget *w) { - /* Nothing to do */ + struct mftk_radio *r = (struct mftk_radio *) w; + + r->children[r->state]->focused = SDL_FALSE; } static int @@ -95,12 +102,16 @@ _mftk_radio_key_event(struct mftk_widget *w, SDL_Event *e) case SDLK_UP: mftk_check_set_state(r->children[ r->state], SDL_FALSE); + r->children[r->state]->focused = + SDL_FALSE; --r->state; if (r->state < 0) { r->state = r->options - 1; } mftk_check_set_state(r->children[ r->state], SDL_TRUE); + r->children[r->state]->focused = + SDL_TRUE; if (r->action == NULL) { return 0; } @@ -108,12 +119,16 @@ _mftk_radio_key_event(struct mftk_widget *w, SDL_Event *e) case SDLK_DOWN: mftk_check_set_state(r->children[ r->state], SDL_FALSE); + r->children[r->state]->focused = + SDL_FALSE; ++r->state; if (r->state >= r->options) { r->state = 0; } mftk_check_set_state(r->children[ r->state], SDL_TRUE); + r->children[r->state]->focused = + SDL_TRUE; if (r->action == NULL) { return 0; } |