本文整理汇总了C++中gcn::KeyEvent::getSource方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getSource方法的具体用法?C++ KeyEvent::getSource怎么用?C++ KeyEvent::getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
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: keyPressed
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: keyPressed
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() );
}
}
}