diff options
author | frosch <frosch@openttd.org> | 2012-11-13 21:46:58 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-11-13 21:46:58 +0000 |
commit | 7699a7dc06049956b90d3f41a14109ee05b97514 (patch) | |
tree | a27f6da660a39ae2345755a1a1c57fbeb2c025b8 /src/misc_gui.cpp | |
parent | fd55399167115dbb06e77bb03f85681ba318f5f2 (diff) | |
download | openttd-7699a7dc06049956b90d3f41a14109ee05b97514.tar.xz |
(svn r24732) -Codechange: Unify handling of OK and CANCEL actions for editboxes.
Diffstat (limited to 'src/misc_gui.cpp')
-rw-r--r-- | src/misc_gui.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index f3f8f5190..868c105a9 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -819,6 +819,20 @@ HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, this->OnOSKInput(wid); break; + case HEBR_CONFIRM: + if (this->ok_button >= 0) { + this->OnClick(Point(), this->ok_button, 1); + } + break; + + case HEBR_CANCEL: + if (this->cancel_button >= 0) { + this->OnClick(Point(), this->cancel_button, 1); + } else { + this->UnfocusFocusedWidget(); + } + break; + default: break; } return result; @@ -905,12 +919,7 @@ struct QueryStringWindow : public QueryStringBaseWindow virtual EventState OnKeyPress(uint16 key, uint16 keycode) { EventState state = ES_NOT_HANDLED; - switch (this->HandleEditBoxKey(WID_QS_TEXT, key, keycode, state)) { - default: break; - case HEBR_CONFIRM: this->OnOk(); - /* FALL THROUGH */ - case HEBR_CANCEL: delete this; break; // close window, abandon changes - } + this->HandleEditBoxKey(WID_QS_TEXT, key, keycode, state); return state; } |