Ejemplo n.º 1
0
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();
    }
}
Ejemplo n.º 2
0
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();
    }
}
Ejemplo n.º 3
0
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());
    }
}
Ejemplo n.º 4
0
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);
		}
	}
}
Ejemplo n.º 5
0
void FileDialog::keyPressed(gcn::KeyEvent& ke)
{
    if(ke.getKey() == gcn::Key::ESCAPE)
    {
        Close();
    }
    else if(ke.getKey() == gcn::Key::ENTER)
    {
        _HandleSelection();
    }
}
Ejemplo n.º 6
0
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);
    }
}
Ejemplo n.º 7
0
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();
}
Ejemplo n.º 8
0
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();
        }
    }
}
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
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();
}
Ejemplo n.º 11
0
// -- 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();
}
Ejemplo n.º 12
0
 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();
     }
 }
Ejemplo n.º 13
0
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);
	}
}
Ejemplo n.º 14
0
void IntroController::keyPressed( gcn::KeyEvent& keyEvent )
{

  if ( keyEvent.getKey().getValue() == gcn::Key::ESCAPE ) {

    model().final(); //! Paramos el bucle asi?.......
    keyEvent.consume();

  }
Ejemplo n.º 15
0
void InventoryWindow::keyReleased(gcn::KeyEvent &event)
{
    switch (event.getKey().getValue())
    {
        case Key::LEFT_SHIFT:
        case Key::RIGHT_SHIFT:
            mSplit = false;
            break;
    }
}
Ejemplo n.º 16
0
void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
    gcn::Key key = keyEvent.getKey();

    if (key.getValue() == Key::ESCAPE)
    {
        action(gcn::ActionEvent(mSwitchLoginButton,
                                mSwitchLoginButton->getActionEventId()));
    }
}
Ejemplo n.º 17
0
    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();
        }
    }
Ejemplo n.º 18
0
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()));
    }
}
Ejemplo n.º 19
0
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;
	}
}
Ejemplo n.º 20
0
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()));
    }
}
Ejemplo n.º 21
0
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("");
        }
    }
}
Ejemplo n.º 22
0
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() );
        }
    }
}
Ejemplo n.º 23
0
    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();
        }
    }
Ejemplo n.º 24
0
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();
    }
}
Ejemplo n.º 25
0
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);
    }
}
Ejemplo n.º 26
0
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());
    }
}
Ejemplo n.º 27
0
void Game::keyPressed(gcn::KeyEvent &keyEvent)
{
    if (keyEvent.getKey().getValue() == gcn::Key::ESCAPE)
    {
        if (mCreditsContainer->isVisible())
        {
            mCreditsContainer->setVisible(false);
            mMainMenuContainer->setVisible(true);
        }
        else if (mHighScoreContainer->isVisible())
        {
            setState(MENU);
        }
        else if (mState != BONUS_LEVEL_OR_SHOP)
        {
            setState(EXIT);
        }
    }
}
Ejemplo n.º 28
0
// -- KeyListener notifications
void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
    gcn::Key key = keyEvent.getKey();

    if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
    {
        distributeActionEvent();
        keyEvent.consume();
    }
    else if (key.getValue() == Key::UP)
    {
        setSelectedRow(mSelectedRow - 1);
        keyEvent.consume();
    }
    else if (key.getValue() == Key::DOWN)
    {
        setSelectedRow(mSelectedRow + 1);
        keyEvent.consume();
    }
    else if (key.getValue() == Key::LEFT)
    {
        setSelectedColumn(mSelectedColumn - 1);
        keyEvent.consume();
    }
    else if (key.getValue() == Key::RIGHT)
    {
        setSelectedColumn(mSelectedColumn + 1);
        keyEvent.consume();
    }
    else if (key.getValue() == Key::HOME)
    {
        setSelectedRow(0);
        setSelectedColumn(0);
        keyEvent.consume();
    }
    else if (key.getValue() == Key::END)
    {
        setSelectedRow(mModel->getRows() - 1);
        setSelectedColumn(mModel->getColumns() - 1);
        keyEvent.consume();
    }
}
Ejemplo n.º 29
0
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);
}
Ejemplo n.º 30
0
// -- 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();
}