Ejemplo n.º 1
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.º 2
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.º 3
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() );
        }
    }
}