mirror of https://github.com/OpenTTD/OpenTTD
(svn r24729) -Codechange: Unify the handling of HEBR_EDITING.
parent
336fcbc50e
commit
6d1fe626f5
|
@ -1341,10 +1341,6 @@ struct AIDebugWindow : public QueryStringBaseWindow {
|
||||||
{
|
{
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) {
|
switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) {
|
||||||
case HEBR_EDITING:
|
|
||||||
this->OnOSKInput(WID_AID_BREAK_STR_EDIT_BOX);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HEBR_CANCEL:
|
case HEBR_CANCEL:
|
||||||
/* Unfocus the text box. */
|
/* Unfocus the text box. */
|
||||||
this->UnfocusFocusedWidget();
|
this->UnfocusFocusedWidget();
|
||||||
|
|
|
@ -697,7 +697,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||||
{
|
{
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
if (this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state) == HEBR_EDITING) this->OnOSKInput(WID_GL_RANDOM_EDITBOX);
|
this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -757,6 +757,9 @@ HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window *osk = FindWindowById(WC_OSK, 0);
|
||||||
|
if (osk != NULL && osk->parent == w) osk->InvalidateData();
|
||||||
|
|
||||||
return HEBR_EDITING;
|
return HEBR_EDITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,7 +813,15 @@ void QueryString::DrawEditBox(const Window *w, int wid) const
|
||||||
|
|
||||||
HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
|
HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
|
||||||
{
|
{
|
||||||
return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
|
HandleEditBoxResult result = this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
|
||||||
|
switch (result) {
|
||||||
|
case HEBR_EDITING:
|
||||||
|
this->OnOSKInput(wid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryStringBaseWindow::OnOpenOSKWindow(int wid)
|
void QueryStringBaseWindow::OnOpenOSKWindow(int wid)
|
||||||
|
@ -898,16 +909,10 @@ struct QueryStringWindow : public QueryStringBaseWindow
|
||||||
{
|
{
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
switch (this->HandleEditBoxKey(WID_QS_TEXT, key, keycode, state)) {
|
switch (this->HandleEditBoxKey(WID_QS_TEXT, key, keycode, state)) {
|
||||||
default: NOT_REACHED();
|
default: break;
|
||||||
case HEBR_EDITING: {
|
|
||||||
Window *osk = FindWindowById(WC_OSK, 0);
|
|
||||||
if (osk != NULL && osk->parent == this) osk->InvalidateData();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HEBR_CONFIRM: this->OnOk();
|
case HEBR_CONFIRM: this->OnOk();
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case HEBR_CANCEL: delete this; break; // close window, abandon changes
|
case HEBR_CANCEL: delete this; break; // close window, abandon changes
|
||||||
case HEBR_NOT_FOCUSED: break;
|
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,17 +511,11 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
} else {
|
} else {
|
||||||
_chat_tab_completion_active = false;
|
_chat_tab_completion_active = false;
|
||||||
switch (this->HandleEditBoxKey(WID_NC_TEXTBOX, key, keycode, state)) {
|
switch (this->HandleEditBoxKey(WID_NC_TEXTBOX, key, keycode, state)) {
|
||||||
default: NOT_REACHED();
|
default: break;
|
||||||
case HEBR_EDITING: {
|
|
||||||
Window *osk = FindWindowById(WC_OSK, 0);
|
|
||||||
if (osk != NULL && osk->parent == this) osk->InvalidateData();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HEBR_CONFIRM:
|
case HEBR_CONFIRM:
|
||||||
SendChat(this->text.buf, this->dtype, this->dest);
|
SendChat(this->text.buf, this->dtype, this->dest);
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case HEBR_CANCEL: delete this; break;
|
case HEBR_CANCEL: delete this; break;
|
||||||
case HEBR_NOT_FOCUSED: break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -766,10 +766,7 @@ public:
|
||||||
default: {
|
default: {
|
||||||
/* Handle editbox input */
|
/* Handle editbox input */
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
if (this->HandleEditBoxKey(WID_NCL_FILTER, key, keycode, state) == HEBR_EDITING) {
|
this->HandleEditBoxKey(WID_NCL_FILTER, key, keycode, state);
|
||||||
this->OnOSKInput(WID_NCL_FILTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -847,11 +847,7 @@ public:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HEBR_CONFIRM:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->OnOSKInput(WID_NG_CLIENT);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,16 +1180,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||||
{
|
{
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
switch (this->HandleEditBoxKey(WID_NSS_GAMENAME, key, keycode, state)) {
|
this->HandleEditBoxKey(WID_NSS_GAMENAME, key, keycode, state);
|
||||||
case HEBR_CONFIRM:
|
|
||||||
case HEBR_NOT_FOCUSED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
this->OnOSKInput(WID_NSS_GAMENAME);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1265,9 +1265,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
|
||||||
default: {
|
default: {
|
||||||
/* Handle editbox input */
|
/* Handle editbox input */
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
if (this->HandleEditBoxKey(WID_NS_FILTER, key, keycode, state) == HEBR_EDITING) {
|
this->HandleEditBoxKey(WID_NS_FILTER, key, keycode, state);
|
||||||
this->OnOSKInput(WID_NS_FILTER);
|
|
||||||
}
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2410,9 +2410,7 @@ struct GameSettingsWindow : QueryStringBaseWindow {
|
||||||
{
|
{
|
||||||
/* Handle editbox input */
|
/* Handle editbox input */
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
if (this->HandleEditBoxKey(WID_GS_FILTER, key, keycode, state) == HEBR_EDITING) {
|
this->HandleEditBoxKey(WID_GS_FILTER, key, keycode, state);
|
||||||
this->OnOSKInput(WID_GS_FILTER);
|
|
||||||
}
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,10 +297,6 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
{
|
{
|
||||||
EventState state = ES_NOT_HANDLED;
|
EventState state = ES_NOT_HANDLED;
|
||||||
switch (this->HandleEditBoxKey(WID_SIL_FILTER_TEXT, key, keycode, state)) {
|
switch (this->HandleEditBoxKey(WID_SIL_FILTER_TEXT, key, keycode, state)) {
|
||||||
case HEBR_EDITING:
|
|
||||||
this->OnOSKInput(WID_SIL_FILTER_TEXT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HEBR_CONFIRM: // Enter pressed -> goto first sign in list
|
case HEBR_CONFIRM: // Enter pressed -> goto first sign in list
|
||||||
if (this->signs.Length() >= 1) {
|
if (this->signs.Length() >= 1) {
|
||||||
const Sign *si = this->signs[0];
|
const Sign *si = this->signs[0];
|
||||||
|
@ -322,7 +318,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NOT_REACHED();
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in New Issue