summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-13 21:46:58 +0000
committerfrosch <frosch@openttd.org>2012-11-13 21:46:58 +0000
commit7699a7dc06049956b90d3f41a14109ee05b97514 (patch)
treea27f6da660a39ae2345755a1a1c57fbeb2c025b8 /src/ai
parentfd55399167115dbb06e77bb03f85681ba318f5f2 (diff)
downloadopenttd-7699a7dc06049956b90d3f41a14109ee05b97514.tar.xz
(svn r24732) -Codechange: Unify handling of OK and CANCEL actions for editboxes.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_gui.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 26e794c89..e4320ae17 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1340,29 +1340,18 @@ struct AIDebugWindow : public QueryStringBaseWindow {
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
EventState state = ES_NOT_HANDLED;
- switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) {
- case HEBR_CANCEL:
- /* Unfocus the text box. */
- this->UnfocusFocusedWidget();
- break;
-
- case HEBR_NOT_FOCUSED: {
- /* Edit boxs is not globally foused => handle hotkeys of AI Debug window. */
- int num = CheckHotkeyMatch(aidebug_hotkeys, keycode, this);
- if (num == -1) return ES_NOT_HANDLED;
- if (this->show_break_box && num == WID_AID_BREAK_STR_EDIT_BOX) {
- this->SetFocusedWidget(WID_AID_BREAK_STR_EDIT_BOX);
- SetFocusedWindow(this);
- state = ES_HANDLED;
- } else if (this->show_break_box || num < WID_AID_BREAK_STRING_WIDGETS) {
- this->OnClick(Point(), num, 1);
- state = ES_HANDLED;
- }
- break;
+ if (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state) == HEBR_NOT_FOCUSED) {
+ /* Edit boxs is not globally foused => handle hotkeys of AI Debug window. */
+ int num = CheckHotkeyMatch(aidebug_hotkeys, keycode, this);
+ if (num == -1) return ES_NOT_HANDLED;
+ if (this->show_break_box && num == WID_AID_BREAK_STR_EDIT_BOX) {
+ this->SetFocusedWidget(WID_AID_BREAK_STR_EDIT_BOX);
+ SetFocusedWindow(this);
+ state = ES_HANDLED;
+ } else if (this->show_break_box || num < WID_AID_BREAK_STRING_WIDGETS) {
+ this->OnClick(Point(), num, 1);
+ state = ES_HANDLED;
}
-
- default:
- break;
}
return state;
}