Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-13 16:41:39 +0000
committerStijn Buys <ingar@osirion.org>2009-08-13 16:41:39 +0000
commit9f8804390d9ad183a05dc5f4d8f99627e71a791e (patch)
tree41940079081663b86018ebf56d7f91b6f39fd567 /src/ui
parenta320e55dc1a17cef3923643277f1112f74251d70 (diff)
improved menu ESC handling
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/menu.cc18
-rw-r--r--src/ui/menu.h3
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;