コード例 #1
0
ファイル: ChatBox.cpp プロジェクト: hoodwolf/Infraelly
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("");
        }
    }
}
コード例 #2
0
ファイル: menu.cpp プロジェクト: olofn/db_public
    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();
        }
    }
コード例 #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() );
        }
    }
}