summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-14 22:50:39 +0000
committerfrosch <frosch@openttd.org>2012-11-14 22:50:39 +0000
commitc283a412485700ab8e81a374f080c1ef94fbf64d (patch)
tree4673dc71eac8f915dcbc6b846213157096260357 /src/window.cpp
parentf5d8ba5d7f90abc72db6c0470da383ecf82da487 (diff)
downloadopenttd-c283a412485700ab8e81a374f080c1ef94fbf64d.tar.xz
(svn r24743) -Change: Unify the behaviour of ESC in filter editboxes.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 665fabcf8..088233fc0 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2265,6 +2265,8 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
QueryString *query = this->GetQueryString(wid);
if (query == NULL) return state;
+ int action = QueryString::ACTION_NOTHING;
+
switch (query->HandleEditBoxKey(this, wid, key, keycode, state)) {
case HEBR_EDITING:
this->OnEditboxChanged(wid);
@@ -2273,6 +2275,8 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
case HEBR_CONFIRM:
if (query->ok_button >= 0) {
this->OnClick(Point(), query->ok_button, 1);
+ } else {
+ action = query->ok_button;
}
break;
@@ -2280,13 +2284,28 @@ EventState Window::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
if (query->cancel_button >= 0) {
this->OnClick(Point(), query->cancel_button, 1);
} else {
- this->UnfocusFocusedWidget();
+ action = query->cancel_button;
}
break;
default: break;
}
+ switch (action) {
+ case QueryString::ACTION_DESELECT:
+ this->UnfocusFocusedWidget();
+ break;
+
+ case QueryString::ACTION_CLEAR:
+ query->text.DeleteAll();
+ this->SetWidgetDirty(wid);
+ this->OnEditboxChanged(wid);
+ break;
+
+ default:
+ break;
+ }
+
return state;
}