Changeset - r19778:979f3421fa37
[Not reviewed]
master
0 13 0
frosch - 12 years ago 2012-11-13 21:47:02
frosch@openttd.org
(svn r24733) -Codechange: Move handling of editbox keys to window class.
13 files changed with 34 insertions and 94 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -1340,10 +1340,8 @@ struct AIDebugWindow : public QueryStrin
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		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;
 
		int num = CheckHotkeyMatch(aidebug_hotkeys, keycode, this);
 
		if (num != -1) {
 
			if (this->show_break_box && num == WID_AID_BREAK_STR_EDIT_BOX) {
 
				this->SetFocusedWidget(WID_AID_BREAK_STR_EDIT_BOX);
 
				SetFocusedWindow(this);
src/fios_gui.cpp
Show inline comments
 
@@ -622,10 +622,7 @@ public:
 
			return ES_HANDLED;
 
		}
 

	
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_SL_SAVE_OSK_TITLE, key, keycode, state);
 

	
 
		return state;
 
		return ES_NOT_HANDLED;
 
	}
 

	
 
	virtual void OnTimeout()
src/genworld_gui.cpp
Show inline comments
 
@@ -694,13 +694,6 @@ struct GenerateLandscapeWindow : public 
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state);
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_GL_RANDOM_EDITBOX) {
src/misc_gui.cpp
Show inline comments
 
@@ -811,10 +811,10 @@ void QueryString::DrawEditBox(const Wind
 
	_cur_dpi = old_dpi;
 
}
 

	
 
HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
 
EventState QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode)
 
{
 
	HandleEditBoxResult result = this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
 
	switch (result) {
 
	EventState state = ES_NOT_HANDLED;
 
	switch (this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state)) {
 
		case HEBR_EDITING:
 
			this->OnOSKInput(wid);
 
			break;
 
@@ -835,7 +835,7 @@ HandleEditBoxResult QueryStringBaseWindo
 

	
 
		default: break;
 
	}
 
	return result;
 
	return state;
 
}
 

	
 
/** Class for the string query window. */
 
@@ -916,13 +916,6 @@ struct QueryStringWindow : public QueryS
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_QS_TEXT, key, keycode, state);
 
		return state;
 
	}
 

	
 
	~QueryStringWindow()
 
	{
 
		if (!this->handled && this->parent != NULL) {
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -510,13 +510,15 @@ struct NetworkChatWindow : public QueryS
 
		if (keycode == WKC_TAB) {
 
			ChatTabCompletion();
 
			state = ES_HANDLED;
 
		} else {
 
			_chat_tab_completion_active = false;
 
			this->HandleEditBoxKey(WID_NC_TEXTBOX, key, keycode, state);
 
		}
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		_chat_tab_completion_active = false;
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
src/network/network_content_gui.cpp
Show inline comments
 
@@ -763,12 +763,8 @@ public:
 
				}
 
				/* FALL THROUGH, space is pressed and filter isn't focused. */
 

	
 
			default: {
 
				/* Handle editbox input */
 
				EventState state = ES_NOT_HANDLED;
 
				this->HandleEditBoxKey(WID_NCL_FILTER, key, keycode, state);
 
				return state;
 
			}
 
			default:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		if (_network_content_client.Length() == 0) return ES_HANDLED;
src/network/network_gui.cpp
Show inline comments
 
@@ -835,14 +835,12 @@ public:
 
			return ES_HANDLED;
 
		}
 

	
 
		if (this->HandleEditBoxKey(WID_NG_CLIENT, key, keycode, state) == HEBR_NOT_FOCUSED) {
 
			if (this->server != NULL) {
 
				if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
 
					NetworkGameListRemoveItem(this->server);
 
					if (this->server == this->last_joined) this->last_joined = NULL;
 
					this->server = NULL;
 
					this->list_pos = SLP_INVALID;
 
				}
 
		if (this->server != NULL) {
 
			if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
 
				NetworkGameListRemoveItem(this->server);
 
				if (this->server == this->last_joined) this->last_joined = NULL;
 
				this->server = NULL;
 
				this->list_pos = SLP_INVALID;
 
			}
 
		}
 

	
 
@@ -1172,13 +1170,6 @@ struct NetworkStartServerWindow : public
 
		this->SetDirty();
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_NSS_GAMENAME, key, keycode, state);
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_NSS_GAMENAME) {
 
@@ -2151,13 +2142,6 @@ struct NetworkCompanyPasswordWindow : pu
 
				break;
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_NCP_PASSWORD, key, keycode, state);
 
		return state;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_network_company_password_window_widgets[] = {
src/newgrf_gui.cpp
Show inline comments
 
@@ -1262,12 +1262,8 @@ struct NewGRFWindow : public QueryString
 
				this->avail_pos = this->avails.Length() - 1;
 
				break;
 

	
 
			default: {
 
				/* Handle editbox input */
 
				EventState state = ES_NOT_HANDLED;
 
				this->HandleEditBoxKey(WID_NS_FILTER, key, keycode, state);
 
				return state;
 
			}
 
			default:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		if (this->avails.Length() == 0) this->avail_pos = -1;
src/querystring_gui.h
Show inline comments
 
@@ -78,7 +78,7 @@ struct QueryStringBaseWindow : public Wi
 
		free(this->edit_str_buf);
 
	}
 

	
 
	HandleEditBoxResult HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
 
	EventState HandleEditBoxKey(int wid, uint16 key, uint16 keycode);
 

	
 
	/**
 
	 * Callback for when on input has been entered with the OSK.
src/settings_gui.cpp
Show inline comments
 
@@ -2406,14 +2406,6 @@ struct GameSettingsWindow : QueryStringB
 
		this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		/* Handle editbox input */
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_GS_FILTER, key, keycode, state);
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_GS_FILTER) {
src/signs_gui.cpp
Show inline comments
 
@@ -306,12 +306,10 @@ struct SignListWindow : QueryStringBaseW
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		if (this->HandleEditBoxKey(WID_SIL_FILTER_TEXT, key, keycode, state) == HEBR_NOT_FOCUSED) {
 
			if (CheckHotkeyMatch(signlist_hotkeys, keycode, this) == SLHK_FOCUS_FILTER_BOX) {
 
				this->SetFocusedWidget(WID_SIL_FILTER_TEXT);
 
				SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
 
				state = ES_HANDLED;
 
			}
 
		if (CheckHotkeyMatch(signlist_hotkeys, keycode, this) == SLHK_FOCUS_FILTER_BOX) {
 
			this->SetFocusedWidget(WID_SIL_FILTER_TEXT);
 
			SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
 
			state = ES_HANDLED;
 
		}
 

	
 
		return state;
 
@@ -540,13 +538,6 @@ struct SignWindow : QueryStringBaseWindo
 
				break;
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_QES_TEXT, key, keycode, state);
 
		return state;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_query_sign_edit_widgets[] = {
src/town_gui.cpp
Show inline comments
 
@@ -1101,13 +1101,6 @@ public:
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_TF_TOWN_NAME_EDITBOX, key, keycode, state);
 
		return state;
 
	}
 

	
 
	virtual void OnPlaceObject(Point pt, TileIndex tile)
 
	{
 
		this->ExecuteFoundTownCommand(tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
src/window.cpp
Show inline comments
 
@@ -2263,8 +2263,13 @@ void HandleKeypress(uint32 raw_key)
 

	
 
	/* Check if the focused window has a focused editbox */
 
	if (EditBoxInGlobalFocus()) {
 
		/* All input will in this case go to the focused window */
 
		if (_focused_window->OnKeyPress(key, keycode) == ES_HANDLED) return;
 
		/* All input will in this case go to the focused editbox */
 
		if (_focused_window->window_class == WC_CONSOLE) {
 
			if (_focused_window->OnKeyPress(key, keycode) == ES_HANDLED) return;
 
		} else {
 
			QueryStringBaseWindow *query = dynamic_cast<QueryStringBaseWindow*>(_focused_window);
 
			if (query != NULL && query->HandleEditBoxKey(_focused_window->nested_focus->index, key, keycode) == ES_HANDLED) return;
 
		}
 
	}
 

	
 
	/* Call the event, start with the uppermost window, but ignore the toolbar. */
0 comments (0 inline, 0 general)