本文整理汇总了C++中KeyEvent类的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent类的具体用法?C++ KeyEvent怎么用?C++ KeyEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyUp
void gravApp::keyUp( KeyEvent event)
{
if( event.getChar() == ' ' ){
if(turn == 1)
moon1->jump();
if(turn == 2)
moon2->jump();
}
}
示例2: on_key_press
void ListBoxViewImpl::on_key_press(KeyEvent &e)
{
if (listbox->content_view()->children().empty())
return;
if (e.key() == Key::up)
{
listbox->set_selected_item(clan::max(selected_item - 1, 0));
if (func_selection_changed)
func_selection_changed();
}
else if (e.key() == Key::down)
{
listbox->set_selected_item(clan::min(selected_item + 1, (int)listbox->content_view()->children().size() - 1));
if (func_selection_changed)
func_selection_changed();
}
}
示例3: switch
void Application::keyDown(KeyEvent event)
{
switch (event.getCode())
{
case KeyEvent::KEY_ESCAPE:
quit();
break;
}
}
示例4: keyDown
void MemExploreApp::keyDown(KeyEvent e)
{
if(e.getCode() == 27) { // Esc
mIsFullscreen = false;
setFullScreen(mIsFullscreen);
}
else if(e.getChar() == 'f') {
mIsFullscreen = true;
setFullScreen(mIsFullscreen);
}
else if(e.getChar() == ' ') {
delete mDataPointer;
mDataPointer = new uint8_t;
}
else {
mKeysDown.insert(e.getChar());
}
}
示例5: nativeSendKeyEvent
static jlong nativeSendKeyEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj,
jboolean predispatch) {
InputQueue* queue = reinterpret_cast<InputQueue*>(ptr);
KeyEvent* event = queue->createKeyEvent();
status_t status = android_view_KeyEvent_toNative(env, eventObj, event);
if (status) {
queue->recycleInputEvent(event);
jniThrowRuntimeException(env, "Could not read contents of KeyEvent object.");
return -1;
}
if (predispatch) {
event->setFlags(event->getFlags() | AKEY_EVENT_FLAG_PREDISPATCH);
}
queue->enqueueEvent(event);
return reinterpret_cast<jlong>(event);
}
示例6:
void NessBox2DApp::setKeysTo(const KeyEvent event, const bool what) {
for (int i = 0; i < 5; i++) {
if ( (what && !keys[i]) || (!what && keys[i]) ) { // only update if setting != what
if(event.getCode() == definedKeys[i]) {
keys[i] = what;
}
}
}
}
示例7: keyUp
void ControleaseApp::keyUp( KeyEvent event )
{
if (event.getChar() == ' ') {
bUpdate = !bUpdate;
}
else {
canvas->appKeyUp(event);
}
}
示例8: keyDown
void wellingtonModelApp::keyDown(KeyEvent event)
{
if(event.getCode() == 27){
if(mWaterModule != NULL){
delete mWaterModule;
}
exit(0);
}
}
示例9: keyUp
void BasicApp::keyUp( KeyEvent event )
{
if( event.getCode() == KeyEvent::KEY_RIGHT)
{
if(game_state == GAME_Play)
{
currentShip.right = false;
}
}
if( event.getCode() == KeyEvent::KEY_LEFT)
{
if(game_state == GAME_Play)
{
currentShip.left = false;
}
}
if( event.getCode() == KeyEvent::KEY_UP)
{
if(game_state == GAME_Play)
{
currentShip.m_Thrust = false;
currentShip.up = false;
}
}
if(event.getCode() ==KeyEvent::KEY_SPACE)
{
if(game_state == GAME_Play)
{
if(!currentShip.up)
{
currentShip.m_Thrust = false;;
}
currentShip.fire = false;
currentShip.m_fire = 0;
}
else if ( game_state == Game_Demo)
{
game_state = GAME_Play;
}
}
}
示例10: keyDown
void VoiceBasicApp::keyDown( KeyEvent event )
{
// space toggles the voice between playing and pausing
if( event.getCode() == KeyEvent::KEY_SPACE ) {
if( mVoice->isPlaying() )
mVoice->pause();
else
mVoice->start();
}
}
示例11: onKeyReleased
bool OgreNodeDebuggerComponent::onKeyReleased(const KeyEvent & evt)
{
KeyMap::iterator it = _keyMap.find(evt.getKey());
if(it != _keyMap.end())
{
it->second.first = false;
}
return false;
}
示例12: keyDown
void cApp::keyDown( KeyEvent event ) {
char key = event.getChar();
switch (key) {
case 'S': mExp.startRender(); break;
case 'T': mExp.stopRender(); break;
case 's': mExp.snapShot(); break;
case ' ': bStart = !bStart; break;
case 'c': mt::printCamera( camUi.getCamera() ); break;
}
}
示例13:
/*
* Whenever the letter 'r' is pressed on the keyboard, the linked list is reversed, causing the last rectangle
* (which was previously being overlapped by all other rectangles) to overlap all other rectangles and the first
* rectangle (which was previously overlapping all other rectangles) to be overlapped by all other rectangles.
* @param event: The event in which the letter 'r' is pressed on the keyboard.
*/
void MelinkJLHW02App::keyDown(KeyEvent event)
{
int keyPressed = event.getChar();
if (keyPressed == 'r')
{
(*linkedList).reverse();
(*linkedList).resize();
}
}
示例14: TEST_F
TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesKeyEvents) {
KeyEvent event;
// Rejects undefined key actions.
event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
/*action*/ -1, 0,
AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(&event,
INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
<< "Should reject key events with undefined action.";
// Rejects ACTION_MULTIPLE since it is not supported despite being defined in the API.
event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
AKEY_EVENT_ACTION_MULTIPLE, 0,
AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(&event,
INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
<< "Should reject key events with ACTION_MULTIPLE.";
}
示例15: switch
void DepthProcessor::keyDown( KeyEvent event )
{
switch( event.getCode() ){
case KeyEvent::KEY_a:
resetBackground();
break;
default:
break;
}
}