diff options
author | Stijn Buys <ingar@osirion.org> | 2009-08-13 16:41:39 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-08-13 16:41:39 +0000 |
commit | 9f8804390d9ad183a05dc5f4d8f99627e71a791e (patch) | |
tree | 41940079081663b86018ebf56d7f91b6f39fd567 /src/ui | |
parent | a320e55dc1a17cef3923643277f1112f74251d70 (diff) |
improved menu ESC handling
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/menu.cc | 18 | ||||
-rw-r--r-- | src/ui/menu.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/ui/menu.cc b/src/ui/menu.cc index f1364ac..716f5b4 100644 --- a/src/ui/menu.cc +++ b/src/ui/menu.cc @@ -61,4 +61,22 @@ void Menu::resize() menu_container->set_location(ui::UI::elementsize.height(), (height() - menu_container->height()) / 2.0f); } +bool Menu::on_keypress(const int key, const unsigned int modifier) +{ + switch( key ) { + + case SDLK_ESCAPE: + if (visible()) { + this->hide(); + return true; + } + break; + + default: + break; + } + + return Window::on_keypress(key, modifier); +} + } diff --git a/src/ui/menu.h b/src/ui/menu.h index bbcea5a..c907d76 100644 --- a/src/ui/menu.h +++ b/src/ui/menu.h @@ -40,6 +40,9 @@ public: protected: /// resize event virtual void resize(); + + /// keypress event + virtual bool on_keypress(const int key, const unsigned int modifier); private: Bitmap *menu_background; |