void PlayControllerZone::keyPressed( gcn::KeyEvent& keyEvent ) { switch ( keyEvent.getKey().getValue() ) { case gcn::Key::LEFT: view().Scroll( 1, IMap::WEST ); break; case gcn::Key::RIGHT: view().Scroll( 1, IMap::EAST ); break; case gcn::Key::UP: view().Scroll( 1, IMap::NORTH ); break; case gcn::Key::DOWN: view().Scroll( 1, IMap::SOUTH ); break; default: ; } keyEvent.consume(); }
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed() || !isFocused()) return; if (keyEvent.getKey().getValue() == Key::LEFT) { int index = getSelectedTabIndex(); index--; if (index < 0) setSelectedTab(mTabs[mTabs.size() - 1].first); else setSelectedTab(mTabs[index].first); keyEvent.consume(); } else if (keyEvent.getKey().getValue() == Key::RIGHT) { int index = getSelectedTabIndex(); index++; if (index >= (int) mTabs.size()) setSelectedTab(mTabs[0].first); else setSelectedTab(mTabs[index].first); keyEvent.consume(); } }
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed() || !isFocused()) return; if (keyEvent.getKey().getValue() == Key::LEFT) { TabContainer::iterator index = getTabIterator(mSelectedTab); if (index != mTabs.begin()) setSelectedTab((--index)->first); else setSelectedTab((--mTabs.end())->first); keyEvent.consume(); } else if (keyEvent.getKey().getValue() == Key::RIGHT) { TabContainer::iterator index = getTabIterator(mSelectedTab); if (index != (--mTabs.end())) setSelectedTab((++index)->first); else setSelectedTab(mTabs.begin()->first); keyEvent.consume(); } }
// -- KeyListener notifications void ListBox::keyPressed(gcn::KeyEvent& keyEvent) { gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) { if (keyEvent.isShiftPressed()) { const std::string actionEventId = getActionEventId(); setActionEventId("default"); distributeActionEvent(); setActionEventId(actionEventId); } else distributeActionEvent(); } else if (key.getValue() == Key::UP) decrementSelected(); else if (key.getValue() == Key::DOWN) incrementSelected(); else if (key.getValue() == Key::HOME) setSelected(0); else if (key.getValue() == Key::END) setSelected(getListModel()->getNumberOfElements() - 1); else return; keyEvent.consume(); }
void ChatInput::keyPressed(gcn::KeyEvent &event) { TextField::keyPressed(event); if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end()) { // Move forward through the history HistoryIterator prevHist = mCurHist++; if (mCurHist != mHistory.end()) { setText(*mCurHist); setCaretPosition(getText().length()); } else mCurHist = prevHist; } else if (event.getKey().getValue() == Key::UP && mCurHist != mHistory.begin() && mHistory.size() > 0) { // Move backward through the history mCurHist--; setText(*mCurHist); setCaretPosition(getText().length()); } }
void Slider::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); if (getOrientation() == HORIZONTAL) { if (key.getValue() == Key::RIGHT) { setValue(getValue() + getStepLength()); distributeActionEvent(); keyEvent.consume(); } else if (key.getValue() == Key::LEFT) { setValue(getValue() - getStepLength()); distributeActionEvent(); keyEvent.consume(); } } else { if (key.getValue() == Key::UP) { setValue(getValue() + getStepLength()); distributeActionEvent(); keyEvent.consume(); } else if (key.getValue() == Key::DOWN) { setValue(getValue() - getStepLength()); distributeActionEvent(); keyEvent.consume(); } } }
void IntTextField::keyPressed(gcn::KeyEvent &event) { int action = static_cast<KeyEvent*>(&event)->getActionId(); if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE) { setText(std::string()); if (mSendAlwaysEvents) distributeActionEvent(); event.consume(); } if (!event.getKey().isNumber()) return; TextField::keyPressed(event); std::istringstream s(getText()); int i; s >> i; setValue(i); if (mSendAlwaysEvents) distributeActionEvent(); }
void GlassWidget::keyReleased(gcn::KeyEvent &e) { if(me) { PyObject *res = PyObject_CallMethod(me, "_keyReleased", "(ii)", e.getType(), e.getKey().getValue()); if(res == NULL && PyErr_Occurred() != NULL) Py_HandleError(); else Py_XDECREF(res); } }
void IntroController::keyPressed( gcn::KeyEvent& keyEvent ) { if ( keyEvent.getKey().getValue() == gcn::Key::ESCAPE ) { model().final(); //! Paramos el bucle asi?....... keyEvent.consume(); }
void DBSH07TextField::keyPressed(gcn::KeyEvent &keyEvent) { if (keyEvent.getKey().getValue() != ',') { if (getText().size() < 10 || keyEvent.getKey().getValue() == gcn::Key::BACKSPACE || keyEvent.getKey().getValue() == gcn::Key::ENTER) { gcn::TextField::keyPressed(keyEvent); } } }
void FileDialog::keyPressed(gcn::KeyEvent& ke) { if(ke.getKey() == gcn::Key::ESCAPE) { Close(); } else if(ke.getKey() == gcn::Key::ENTER) { _HandleSelection(); } }
void ChatBox::keyPressed(gcn::KeyEvent& keyEvent){ //if( keyEvent.isConsumed() ){ return; } //if enter pressed if( keyEvent.getKey().getValue() == gcn::Key::ENTER ){ // on the input field if ( keyEvent.getSource() == inputField ){ // add the text from the text field into the chat area push_back( inputField->getText(), DO_CALLBACK|PUT_USERNAME ); //clear off the text field inputField->setText(""); } } }
void Menu::keyPressed(gcn::KeyEvent& keyEvent) { std::cout << "Menu::keyPressed" << std::endl; hikari::Input::Button button = InputHelper::getMappedButtonForKey(keyEvent.getKey()); if(button == Input::BUTTON_UP) { selectPreviousItem(); keyEvent.consume(); } else if(button == Input::BUTTON_DOWN) { selectNextItem(); keyEvent.consume(); } else if(button == Input::BUTTON_START || button == Input::BUTTON_SHOOT) { distributeActionEvent(); } }
void FFScrollArea::keyPressed(gcn::KeyEvent &keyEvent) { if (keyEvent.isConsumed()) { return; } if (keyEvent.getKey().getValue() == gcn::Key::Down) { setVerticalScrollAmount(getVerticalScrollAmount() + 16); } else if (keyEvent.getKey().getValue() == gcn::Key::Up) { setVerticalScrollAmount(getVerticalScrollAmount() - 16); } }
void keyPressed(gcn::KeyEvent& keyEvent) { bool bHandled = false; Uint8 *keystate; gcn::Key key = keyEvent.getKey(); if (key.getValue() == gcn::Key::UP) { keystate = SDL_GetKeyState(NULL); if(keystate[SDLK_RSHIFT]) { int selected = listBox->getSelected() - 10; if(selected < 0) selected = 0; listBox->setSelected(selected); bHandled = true; } } if (key.getValue() == gcn::Key::DOWN) { keystate = SDL_GetKeyState(NULL); if(keystate[SDLK_RSHIFT]) { int selected = listBox->getSelected() + 10; if(selected >= dirList.getNumberOfElements()) selected = dirList.getNumberOfElements() - 1; listBox->setSelected(selected); bHandled = true; } } if(!bHandled) listBox->keyPressed(keyEvent); }
void MultiSelector::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.getKey().getValue() == gcn::Key::DOWN) { setSelected(getSelected() + 1); } else if (keyEvent.getKey().getValue() == gcn::Key::UP) { setSelected(getSelected() - 1); } else if (keyEvent.getKey().getValue() == gcn::Key::SPACE || keyEvent.getKey().getValue() == gcn::Key::LEFT_ALT || keyEvent.getKey().getValue() == gcn::Key::LEFT_CONTROL || keyEvent.getKey().getValue() == gcn::Key::ENTER) { generateAction(); } }
void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) { action(gcn::ActionEvent(mSwitchLoginButton, mSwitchLoginButton->getActionEventId())); } }
void InventoryWindow::keyReleased(gcn::KeyEvent &event) { switch (event.getKey().getValue()) { case Key::LEFT_SHIFT: case Key::RIGHT_SHIFT: mSplit = false; break; } }
void IntTextField::keyPressed(gcn::KeyEvent &event) { const gcn::Key &key = event.getKey(); if (key.getValue() == Key::BACKSPACE || key.getValue() == Key::DELETE) { setText(std::string()); event.consume(); } if (!key.isNumber()) return; TextField::keyPressed(event); std::istringstream s(getText()); int i; s >> i; setValue(i); }
void Menu::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.getKey().getValue() == gcn::Key::SPACE || keyEvent.getKey().getValue() == gcn::Key::LEFT_ALT || keyEvent.getKey().getValue() == gcn::Key::LEFT_CONTROL || keyEvent.getKey().getValue() == gcn::Key::ENTER && keyEvent.getSource() == this) { mGameSelectContainer->setVisible(true); mStartContainer->setVisible(false); mMainMultiSelector->requestFocus(); //generateAction(); } else if (keyEvent.getKey().getValue() == gcn::Key::ESCAPE) { init(); //generateAction(); } }
// -- KeyListener notifications void DropDown::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed()) return; int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (actionId) { case Input::KEY_GUI_SELECT: case Input::KEY_GUI_SELECT2: dropDown(); break; case Input::KEY_GUI_UP: setSelected(getSelected() - 1); break; case Input::KEY_GUI_DOWN: setSelected(getSelected() + 1); break; case Input::KEY_GUI_HOME: setSelected(0); break; case Input::KEY_GUI_END: if (mListBox->getListModel()) { setSelected(mListBox->getListModel()-> getNumberOfElements() - 1); } break; default: return; } keyEvent.consume(); }
void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) { action(gcn::ActionEvent(NULL, mChangeLoginButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId())); } }
// -- KeyListener notifications void DropDown::keyPressed(gcn::KeyEvent& keyEvent) { if (keyEvent.isConsumed()) return; gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) dropDown(); else if (key.getValue() == Key::UP) setSelected(getSelected() - 1); else if (key.getValue() == Key::DOWN) setSelected(getSelected() + 1); else if (key.getValue() == Key::HOME) setSelected(0); else if (key.getValue() == Key::END) setSelected(mListBox->getListModel()->getNumberOfElements() - 1); else return; keyEvent.consume(); }
void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) { Client::setState(STATE_EXIT); } else if (key.getValue() == Key::ENTER) { action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId())); } }
void GlassViewer::keyPressed(gcn::KeyEvent &e) { gcn::Key key = e.getKey(); if (key.getValue() == gcn::Key::LEFT) { position[0] -= 2; } else if (key.getValue() == gcn::Key::RIGHT) { position[0] += 2; } else if (key.getValue() == gcn::Key::UP) { position[2] += 2; } else if (key.getValue() == gcn::Key::DOWN) { position[2] -= 2; } }
void Console::keyPressed(gcn::KeyEvent& keyEvent){ //if( keyEvent.isConsumed() ){ return; }; //if enter pressed if( keyEvent.getKey().getValue() == gcn::Key::ENTER ){ // on the input field if ( keyEvent.getSource() == inputField ){ // add the text from the text field into the text area push_back( inputField->getText(), DO_CALLBACK|PUT_USERNAME ); //store command entered lastCommand = inputField->getText(); //clear off the text field inputField->setText(""); inputField->requestFocus(); } } else if( keyEvent.getKey().getValue() == gcn::Key::UP ){ if( lastCommand != "" ){ inputField->setText(lastCommand); inputField->setCaretPosition( lastCommand.length() ); } } }
void PlayerSetupMenu::keyPressed(gcn::KeyEvent &keyEvent) { int value = keyEvent.getKey().getValue(); if (value == gcn::Key::ESCAPE) { bindNextKey = false; RefreshKeys(); } else if (bindNextKey && Menu::lastKeyPressed) { ConfigManager::SetPlayerControl(currentPlayer, actionToBind, Input::GetKeyString(Menu::lastKeyPressed)); bindNextKey = false; RefreshKeys(); } }
void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) { int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (actionId) { case Input::KEY_GUI_CANCEL: keyEvent.consume(); action(gcn::ActionEvent(mCancelButton, mCancelButton->getActionEventId())); break; default: break; } }
void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) { const gcn::Key &key = keyEvent.getKey(); int dir = 0; switch (key.getValue()) { case Key::ENTER: action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); break; case Key::ESCAPE: action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); break; case Key::UP: dir = -1; break; case Key::DOWN: dir = 1; break; } if (dir != 0) { std::vector<gcn::RadioButton*>::iterator it = mOptions.begin(); for (; it < mOptions.end(); it++) { if ((*it)->isSelected()) break; } if (it == mOptions.end()) { mOptions[0]->setSelected(true); return; } else if (it == mOptions.begin() && dir < 0) it = mOptions.end(); it += dir; if (it == mOptions.end()) it = mOptions.begin(); (*it)->setSelected(true); } }
void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) { gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) { action(gcn::ActionEvent(NULL, mServerButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { action(gcn::ActionEvent(NULL, mLoginButton->getActionEventId())); } else { mLoginButton->setEnabled(canSubmit()); } }