virtual EventState OnHotkey(int hotkey) { switch (hotkey) { case 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. break; default: return ES_NOT_HANDLED; } return ES_HANDLED; }
void OpenGLGUI::AddWindow(GUIWindow* window) { window->SetDepth(m_currentWindowDepth); window->SetAudio(m_audio); window->SetAudioVolume(m_audioVolume); // Windows are seperated by a depth of 5 m_currentWindowDepth += 10.0f; window->SetDepth(m_currentWindowDepth); m_vpGUIWindowList.push_back(window); window->SetGUIParent(this); // Make sure the last added window is the focus window SetFocusedWindow(window); window->AddEventListeners(); DepthSortGUIWindowChildren(); }
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; }