diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-08-06 16:40:17 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-08-06 16:40:17 (EDT) |
commit | c81ec0dd9447a4388b9d250d6db2ff98d9689af6 (patch) | |
tree | e9c007839f5d52b57412c127483d00bbe9e4b1ea /src/tk | |
parent | 213e8511db7356ce3abb852fc437797f252308d0 (diff) | |
download | mazefight-c81ec0dd9447a4388b9d250d6db2ff98d9689af6.zip mazefight-c81ec0dd9447a4388b9d250d6db2ff98d9689af6.tar.gz mazefight-c81ec0dd9447a4388b9d250d6db2ff98d9689af6.tar.bz2 |
tk: Add button key handling
Diffstat (limited to 'src/tk')
-rw-r--r-- | src/tk/button.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tk/button.c b/src/tk/button.c index 4b25d17..ef7cf6c 100644 --- a/src/tk/button.c +++ b/src/tk/button.c @@ -46,7 +46,21 @@ _mftk_button_key_event(struct mftk_widget *w, SDL_Event *e) { struct mftk_button *b = (struct mftk_button *) w; - /* TODO */ + switch (e->type) { + case SDL_KEYDOWN: + switch (e->key.keysym.sym) { + case SDLK_SPACE: + case SDLK_RETURN: + if (b->action == NULL) { + return 0; + } + return b->action(b->user_data); + default: + break; + } + default: + break; + } return 0; } |