summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-03-17 13:05:45 +0000
committerfrosch <frosch@openttd.org>2013-03-17 13:05:45 +0000
commitc2c50b0c507d427caa32f71eda009bba95fac684 (patch)
treef21279587550f7711729c87c56ab67369e6c3799 /src/window.cpp
parent1ddf5a0786a59431c3092673fd65a7a8aca755a3 (diff)
downloadopenttd-c2c50b0c507d427caa32f71eda009bba95fac684.tar.xz
(svn r25092) -Codechange: Deduplicate keyboard handling between console and editboxes.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/window.cpp b/src/window.cpp
index f818471bd..d223f5cfd 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2250,26 +2250,24 @@ static bool MaybeBringWindowToFront(Window *w)
*/
EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
{
- EventState state = ES_NOT_HANDLED;
-
QueryString *query = this->GetQueryString(wid);
- if (query == NULL) return state;
+ if (query == NULL) return ES_NOT_HANDLED;
int action = QueryString::ACTION_NOTHING;
- switch (query->HandleEditBoxKey(this, wid, key, keycode, state)) {
- case HEBR_EDITING:
+ switch (query->text.HandleKeyPress(key, keycode)) {
+ case HKPR_EDITING:
this->SetWidgetDirty(wid);
this->OnEditboxChanged(wid);
break;
- case HEBR_CURSOR:
+ case HKPR_CURSOR:
this->SetWidgetDirty(wid);
/* For the OSK also invalidate the parent window */
if (this->window_class == WC_OSK) this->InvalidateData();
break;
- case HEBR_CONFIRM:
+ case HKPR_CONFIRM:
if (this->window_class == WC_OSK) {
this->OnClick(Point(), WID_OSK_OK, 1);
} else if (query->ok_button >= 0) {
@@ -2279,7 +2277,7 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
}
break;
- case HEBR_CANCEL:
+ case HKPR_CANCEL:
if (this->window_class == WC_OSK) {
this->OnClick(Point(), WID_OSK_CANCEL, 1);
} else if (query->cancel_button >= 0) {
@@ -2289,6 +2287,9 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
}
break;
+ case HKPR_NOT_HANDLED:
+ return ES_NOT_HANDLED;
+
default: break;
}
@@ -2307,7 +2308,7 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
break;
}
- return state;
+ return ES_HANDLED;
}
/**