From a6ddfd13f78d8f1a319cc997c81db90bf4b7b8f2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 9 Mar 2013 20:16:30 +0100 Subject: Make checkbox toggle on space-bar key press (release). --- plugingui/checkbox.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugingui/checkbox.cc') diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc index 496de21..5888d3c 100644 --- a/plugingui/checkbox.cc +++ b/plugingui/checkbox.cc @@ -58,6 +58,16 @@ void GUI::CheckBox::registerClickHandler(void (*handler)(void *), void *ptr) this->ptr = ptr; } +void GUI::CheckBox::keyEvent(KeyEvent *e) +{ + if(e->direction != -1) return; + + if(e->keycode == GUI::KeyEvent::KEY_CHARACTER && e->text == " ") { + state = !state; + repaintEvent(NULL); + } +} + void GUI::CheckBox::repaintEvent(GUI::RepaintEvent *e) { // printf("CheckBox::repaintEvent\n"); -- cgit v1.2.3