コード例 #1
0
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
	{
		int num = CheckHotkeyMatch(dockstoolbar_hotkeys, keycode, this);
		if (num == -1) return ES_NOT_HANDLED;
		this->OnClick(Point(), num, 1);
		return ES_HANDLED;
	}
コード例 #2
0
ファイル: signs_gui.cpp プロジェクト: benjeffery/openttd
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
	{
		EventState state = ES_NOT_HANDLED;
		switch (this->HandleEditBoxKey(WID_SIL_FILTER_TEXT, key, keycode, state)) {
			case HEBR_EDITING:
				this->SetFilterString(this->text.buf);
				break;

			case HEBR_CONFIRM: // Enter pressed -> goto first sign in list
				if (this->signs.Length() >= 1) {
					const Sign *si = this->signs[0];
					ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
				}
				return state;

			case HEBR_CANCEL: // ESC pressed, clear filter.
				this->OnClick(Point(), WID_SIL_FILTER_CLEAR_BTN, 1); // Simulate click on clear button.
				this->UnfocusFocusedWidget();                    // Unfocus the text box.
				return state;

			case HEBR_NOT_FOCUSED: // The filter text box is not globaly 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;
				}
				break;

			default:
				NOT_REACHED();
		}

		if (state == ES_HANDLED) OnOSKInput(WID_SIL_FILTER_TEXT);

		return state;
	}