summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-17 23:11:06 +0000
committerrubidium <rubidium@openttd.org>2008-05-17 23:11:06 +0000
commitf5681547efc060ab0cc47c36316c4f2aa1217948 (patch)
treecdbaf12f7c5a7666ecc23983c51dca268e3b58e2 /src/window.cpp
parentc1713c9ab7438386dbda32b4c33e95995882f702 (diff)
downloadopenttd-f5681547efc060ab0cc47c36316c4f2aa1217948.tar.xz
(svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/window.cpp b/src/window.cpp
index b728fed28..5d791d807 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -68,7 +68,7 @@ void Window::OnPaint()
this->HandleWindowEvent(&e);
}
-bool Window::OnKeyPress(uint16 key, uint16 keycode)
+Window::EventState Window::OnKeyPress(uint16 key, uint16 keycode)
{
WindowEvent e;
e.event = WE_KEYPRESS;
@@ -77,17 +77,17 @@ bool Window::OnKeyPress(uint16 key, uint16 keycode)
e.we.keypress.cont = true;
this->HandleWindowEvent(&e);
- return e.we.keypress.cont;
+ return e.we.keypress.cont ? ES_NOT_HANDLED : ES_HANDLED;
}
-bool Window::OnCTRLStateChange()
+Window::EventState Window::OnCTRLStateChange()
{
WindowEvent e;
e.event = WE_CTRL_CHANGED;
e.we.ctrl.cont = true;
this->HandleWindowEvent(&e);
- return e.we.ctrl.cont;
+ return e.we.ctrl.cont ? ES_NOT_HANDLED : ES_HANDLED;
}
void Window::OnClick(Point pt, int widget)
@@ -1802,8 +1802,7 @@ void HandleKeypress(uint32 raw_key)
w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
continue;
}
- ;
- if (!w->OnKeyPress(key, keycode)) return;
+ if (w->OnKeyPress(key, keycode) == Window::ES_HANDLED) return;
}
Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
@@ -1819,7 +1818,7 @@ void HandleCtrlChanged()
/* Call the event, start with the uppermost window. */
for (Window* const *wz = _last_z_window; wz != _z_windows;) {
Window *w = *--wz;
- if (!w->OnCTRLStateChange()) break;
+ if (w->OnCTRLStateChange() == Window::ES_HANDLED) return;
}
}