当前位置: 首页>>代码示例>>C++>>正文


C++ KeyEvent类代码示例

本文整理汇总了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();
	}
}
开发者ID:pholz,项目名称:grav,代码行数:9,代码来源:gravApp.cpp

示例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();
		}
	}
开发者ID:TeoTwawki,项目名称:ClanLib,代码行数:18,代码来源:listbox_view_impl.cpp

示例3: switch

void Application::keyDown(KeyEvent event)
{
    switch (event.getCode())
    {
        case KeyEvent::KEY_ESCAPE:
            quit();
            break;
    }
}
开发者ID:femmebot,项目名称:new-chronotext-toolkit,代码行数:9,代码来源:Application.cpp

示例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());
  }
}
开发者ID:imclab,项目名称:memdescent,代码行数:18,代码来源:MemExploreApp.cpp

示例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);
}
开发者ID:020gzh,项目名称:platform_frameworks_base,代码行数:18,代码来源:android_view_InputQueue.cpp

示例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;
            }
        }
    }
}
开发者ID:ilzxc,项目名称:The-Nature-of-Cinder,代码行数:9,代码来源:NessBox2DApp.cpp

示例7: keyUp

void ControleaseApp::keyUp( KeyEvent event )
{
    if (event.getChar() == ' ') {
        bUpdate = !bUpdate;
    }
    else {
        canvas->appKeyUp(event);
    }
}
开发者ID:galsasson,项目名称:controlease,代码行数:9,代码来源:ControleaseApp.cpp

示例8: keyDown

void wellingtonModelApp::keyDown(KeyEvent event)
{
    if(event.getCode() == 27){
        if(mWaterModule != NULL){
            delete mWaterModule;
        }
        exit(0);
    }
}
开发者ID:chalmersgit,项目名称:wellingtonModel_withWater,代码行数:9,代码来源:wellingtonModelApp.cpp

示例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;
		}
	}
}
开发者ID:AndreAhmed,项目名称:asteroids-atari-clone,代码行数:44,代码来源:basicApp.cpp

示例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();
	}
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:10,代码来源:VoiceBasicApp.cpp

示例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;
}
开发者ID:dbabox,项目名称:aomi,代码行数:10,代码来源:OgreNodeDebuggerComponent.cpp

示例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;
    }
}
开发者ID:stdmtb,项目名称:uf_0.9.0,代码行数:10,代码来源:cApp.cpp

示例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();
	}

}
开发者ID:MelinkJL,项目名称:MelinkJLHW02,代码行数:16,代码来源:MelinkJLHW02App.cpp

示例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.";
}
开发者ID:109021017,项目名称:platform_frameworks_base,代码行数:19,代码来源:InputDispatcher_test.cpp

示例15: switch

void DepthProcessor::keyDown( KeyEvent event )
{
	switch( event.getCode() ){
		case KeyEvent::KEY_a:
      resetBackground();
			break;
		default:
			break;
	}
}
开发者ID:bzztbomb,项目名称:bobbevy_tihwd,代码行数:10,代码来源:bbDepthProcessor.cpp


注:本文中的KeyEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。