summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tk/button.c16
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;
}