diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 16:09:34 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 16:09:34 (GMT) |
| commit | 2652309a3fc4748fa5d983754bc52a7a617898ed (patch) | |
| tree | 6cc254a438bdc92396f9c28bd22c43d248408313 /src/interface/Window.cpp | |
| parent | 36b2aa01918344d91df30c4a6722ac39eaca0642 (diff) | |
| download | powder-2652309a3fc4748fa5d983754bc52a7a617898ed.zip powder-2652309a3fc4748fa5d983754bc52a7a617898ed.tar.gz | |
Nicer defaults for Window closing, Implement these with Sign tool, issue #51. Also set centre as default
Diffstat (limited to 'src/interface/Window.cpp')
| -rw-r--r-- | src/interface/Window.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp index 30e2205..f909af0 100644 --- a/src/interface/Window.cpp +++ b/src/interface/Window.cpp @@ -2,6 +2,7 @@ #include "Window.h" #include "Component.h" #include "interface/Point.h" +#include "interface/Button.h" using namespace ui; @@ -11,7 +12,9 @@ Window::Window(Point _position, Point _size): focusedComponent_(NULL), AllowExclusiveDrawing(true), halt(false), - destruct(false) + destruct(false), + cancelButton(NULL), + okayButton(NULL) #ifdef DEBUG ,debugMode(false) #endif @@ -75,6 +78,18 @@ void Window::RemoveComponent(Component* c) } } +void Window::OnTryExit(ExitMethod method) +{ + if(cancelButton) + cancelButton->DoAction(); +} + +void Window::OnTryOkay(OkayMethod method) +{ + if(okayButton) + okayButton->DoAction(); +} + void Window::RemoveComponent(unsigned idx) { halt = true; @@ -273,6 +288,13 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a } OnKeyPress(key, character, shift, ctrl, alt); + + if(key == KEY_ESCAPE) + OnTryExit(Escape); + + if(key == KEY_ENTER || key == KEY_RETURN) + OnTryOkay(Enter); + if(destruct) finalise(); } @@ -334,6 +356,10 @@ void Window::DoMouseDown(int x_, int y_, unsigned button) } OnMouseDown(x_, y_, button); + + if(x_ < Position.X || y_ < Position.Y || x_ > Position.X+Size.X || y_ > Position.Y+Size.Y) + OnTryExit(MouseOutside); + if(destruct) finalise(); } |
