summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-30 10:51:42 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-30 10:51:42 (GMT)
commit303b546ceb134df48763730cbfd8ce7b6df008a2 (patch)
tree6342d25a285fa1c73407511c2b5f6e6d5601ad0a /src
parent6d5388b221cdd37fe0103e9074edc052053847af (diff)
downloadpowder-303b546ceb134df48763730cbfd8ce7b6df008a2.zip
powder-303b546ceb134df48763730cbfd8ce7b6df008a2.tar.gz
Ensure CTRL, SHIFT and ALT states are reset when Window falls into background
Diffstat (limited to 'src')
-rw-r--r--src/game/GameView.cpp7
-rw-r--r--src/game/GameView.h7
-rw-r--r--src/interface/Engine.cpp6
-rw-r--r--src/interface/Window.cpp12
-rw-r--r--src/interface/Window.h4
5 files changed, 32 insertions, 4 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 610e3ca..d86f2b6 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -1035,6 +1035,13 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
}
}
+void GameView::OnBlur()
+{
+ disableAltBehaviour();
+ disableCtrlBehaviour();
+ disableShiftBehaviour();
+}
+
void GameView::OnTick(float dt)
{
if(selectMode==PlaceSave && !placeSaveThumb)
diff --git a/src/game/GameView.h b/src/game/GameView.h
index b9c0604..4c0ad85 100644
--- a/src/game/GameView.h
+++ b/src/game/GameView.h
@@ -148,6 +148,9 @@ public:
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
+ virtual void OnTick(float dt);
+ virtual void OnDraw();
+ virtual void OnBlur();
//Top-level handers, for Lua interface
virtual void DoDraw();
@@ -158,10 +161,6 @@ public:
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
- //virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
- //virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
- virtual void OnTick(float dt);
- virtual void OnDraw();
class MenuAction;
class ToolAction;
};
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index ddf29c6..bad931c 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -82,6 +82,9 @@ void Engine::ShowWindow(Window * window)
windows.push(state_);
}
+ if(state_)
+ state_->DoBlur();
+
state_ = window;
}
@@ -102,6 +105,9 @@ void Engine::CloseWindow()
}
state_ = windows.top();
windows.pop();
+
+ if(state_)
+ state_->DoFocus();
}
else
{
diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp
index 8dba69a..30e2205 100644
--- a/src/interface/Window.cpp
+++ b/src/interface/Window.cpp
@@ -107,6 +107,18 @@ void Window::DoInitialized()
OnInitialized();
}
+void Window::DoBlur()
+{
+
+ OnBlur();
+}
+
+void Window::DoFocus()
+{
+
+ OnFocus();
+}
+
void Window::DoDraw()
{
OnDraw();
diff --git a/src/interface/Window.h b/src/interface/Window.h
index c2c5e16..83fd1bc 100644
--- a/src/interface/Window.h
+++ b/src/interface/Window.h
@@ -52,6 +52,8 @@ enum ChromeStyle
virtual void DoExit();
virtual void DoTick(float dt);
virtual void DoDraw();
+ virtual void DoFocus();
+ virtual void DoBlur();
virtual void DoMouseMove(int x, int y, int dx, int dy);
virtual void DoMouseDown(int x, int y, unsigned button);
@@ -73,6 +75,8 @@ enum ChromeStyle
virtual void OnExit() {}
virtual void OnTick(float dt) {}
virtual void OnDraw() {}
+ virtual void OnFocus() {}
+ virtual void OnBlur() {}
virtual void OnMouseMove(int x, int y, int dx, int dy) {}
virtual void OnMouseDown(int x, int y, unsigned button) {}