From 55724b08178b077d803f4c3333743bc86b3317cc Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 24 Jan 2010 09:00:51 +0000 Subject: [PATCH] If the keyboard is used for input, ignore where the ENTER key is pressed --- virtual_keyboard.cpp | 12 +++++++++++- virtual_keyboard.hh | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/virtual_keyboard.cpp b/virtual_keyboard.cpp index 8b9b12a..7feca89 100644 --- a/virtual_keyboard.cpp +++ b/virtual_keyboard.cpp @@ -84,6 +84,7 @@ VirtualKeyboard::VirtualKeyboard(Font *font) : GuiView(), ListenerManager() this->sel_x = 0; this->sel_y = 0; this->shift_on = false; + this->kbd_only_input = false; this->is_active = false; this->buf_head = 0; @@ -283,6 +284,8 @@ void VirtualKeyboard::activate() this->is_active = true; memset(this->buf, 0, sizeof(struct virtkey) * this->buf_len); this->buf_head = 0; + + this->kbd_only_input = false; } @@ -403,14 +406,21 @@ void VirtualKeyboard::pushEvent(SDL_Event *ev) case SDLK_RIGHT: case SDLK_PAGEDOWN: case SDLK_PAGEUP: - case SDLK_RETURN: case SDLK_HOME: case SDLK_ESCAPE: /* Handle via the standard widget implementation (except for space) */ + this->kbd_only_input = false; Widget::pushEvent(ev); return; + case SDLK_RETURN: + if (this->kbd_only_input) + this->done(); + else + Widget::pushEvent(ev); + return; case SDLK_SPACE ... SDLK_z: Widget::pushEvent((event_t)(ev->key.keysym.sym)); + this->kbd_only_input = true; default: break; } diff --git a/virtual_keyboard.hh b/virtual_keyboard.hh index 42abb2d..df16936 100644 --- a/virtual_keyboard.hh +++ b/virtual_keyboard.hh @@ -89,6 +89,8 @@ private: int sel_y; bool shift_on; + bool kbd_only_input; + bool is_active; struct virtkey *buf; unsigned buf_head;