summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2019-11-04 18:09:24 +0000
committerCharles Pigott <charlespigott@googlemail.com>2019-11-10 17:58:42 +0000
commit81f159434d9d5421ec188dc7844b6d82dc6aa3e3 (patch)
tree4a27c76cda2355d82ef83a889e0fd03166a76b37
parent46f7c6a641a5f0756e0af8c7701e8775b83a2c03 (diff)
downloadopenttd-81f159434d9d5421ec188dc7844b6d82dc6aa3e3.tar.xz
Codechange: Add EditBoxGainedFocus method to VideoDriver base class
-rw-r--r--src/console_gui.cpp5
-rw-r--r--src/video/video_driver.hpp5
-rw-r--r--src/window.cpp11
-rw-r--r--src/window_gui.h5
4 files changed, 21 insertions, 5 deletions
diff --git a/src/console_gui.cpp b/src/console_gui.cpp
index 916a2ec74..0555f25c6 100644
--- a/src/console_gui.cpp
+++ b/src/console_gui.cpp
@@ -374,6 +374,11 @@ struct IConsoleWindow : Window
this->Scroll(-wheel);
}
+ void OnFocus() override
+ {
+ VideoDriver::GetInstance()->EditBoxGainedFocus();
+ }
+
void OnFocusLost() override
{
VideoDriver::GetInstance()->EditBoxLostFocus();
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index b774c7ba6..d7d853c1f 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -94,6 +94,11 @@ public:
virtual void EditBoxLostFocus() {}
/**
+ * An edit box gained the input focus
+ */
+ virtual void EditBoxGainedFocus() {}
+
+ /**
* Get the currently active instance of the video driver.
*/
static VideoDriver *GetInstance() {
diff --git a/src/window.cpp b/src/window.cpp
index 25e4eb95a..c25751fbb 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -499,11 +499,20 @@ bool Window::SetFocusedWidget(int widget_index)
if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
}
this->nested_focus = this->GetWidget<NWidgetCore>(widget_index);
+ if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxGainedFocus();
return true;
}
/**
- * Called when window looses focus
+ * Called when window gains focus
+ */
+void Window::OnFocus()
+{
+ if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxGainedFocus();
+}
+
+/**
+ * Called when window loses focus
*/
void Window::OnFocusLost()
{
diff --git a/src/window_gui.h b/src/window_gui.h
index db42cafcd..a7e28cf78 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -592,10 +592,7 @@ public:
*/
virtual void SetStringParameters(int widget) const {}
- /**
- * Called when window gains focus
- */
- virtual void OnFocus() {}
+ virtual void OnFocus();
virtual void OnFocusLost();