• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ app::KeyEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ci::app::KeyEvent的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent类的具体用法?C++ KeyEvent怎么用?C++ KeyEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了KeyEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: keyDown

void CircleCropExample::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getCode() == KeyEvent::KEY_d){
		moveCamera(ci::vec3(1.0f, 0.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_a){
		moveCamera(ci::vec3(-1.0f, 0.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_w){
		moveCamera(ci::vec3(0.0f, -1.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_s){
		moveCamera(ci::vec3(0.0f, 1.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_RIGHTBRACKET){
		moveCamera(ci::vec3(0.0f, 0.0f, 1.0f));
	} else if(event.getCode() == KeyEvent::KEY_LEFTBRACKET){
		moveCamera(ci::vec3(0.0f, 0.0f, -1.0f));
	} else if(event.getCode() == KeyEvent::KEY_EQUALS){
		ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
		p.mFarPlane += 1.0f;
		std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
		mEngine.setPerspectiveCamera(1, p);
	} else if(event.getCode() == KeyEvent::KEY_MINUS){
		ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
		p.mFarPlane -= 1.0f;
		std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
		mEngine.setPerspectiveCamera(1, p);
	} else if(event.getCode() == KeyEvent::KEY_c){
		if(mShaderCircleCrop){
			mShaderCircleCrop->setCircleCrop(!mShaderCircleCrop->getCircleCrop());
		}
	}
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:33,代码来源:circlecropexample_app.cpp


示例2: keyDown

void PanoramicVideo::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();

	// Shows all enabled sprites with a label for class type
	} else if(event.getCode() == KeyEvent::KEY_f){

		const int numRoots = mEngine.getRootCount();
		int numPlacemats = 0;
		for(int i = 0; i < numRoots - 1; i++){
			mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
				if(sprite.isEnabled()){
					sprite.setTransparent(false);
					sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
					sprite.setOpacity(0.95f);

					ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
					labelly->setText(typeid(sprite).name());
					labelly->enable(false);
					labelly->setColor(ci::Color::black());
				} else {

					ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
					if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
				}
			}, true);
		}
	}
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:31,代码来源:panoramicvideo_app.cpp


示例3: keyDown

	void ViewController::keyDown(ci::app::KeyEvent &event)
	{
		//  convert char to int
		int selectedInt = event.getChar() - '0';
		if (selectedInt < 0 || selectedInt > mIndicatorNames.size() - 1)
		{
			return;
		}

		activateIndicator(selectedInt);

		switch (event.getChar()) {
		case '0':
			mShapeView->setAlignment(po::scene::Alignment::NONE);
			break;

		case '1':
			mShapeView->setAlignment(po::scene::Alignment::TOP_LEFT);
			break;

		case '2':
			mShapeView->setAlignment(po::scene::Alignment::TOP_CENTER);
			break;

		case '3':
			mShapeView->setAlignment(po::scene::Alignment::TOP_RIGHT);
			break;

		case '4':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_LEFT);
			break;

		case '5':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_CENTER);
			break;

		case '6':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_RIGHT);
			break;

		case '7':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_LEFT);
			break;

		case '8':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_CENTER);
			break;

		case '9':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_RIGHT);
			break;

		default:
			break;
		}
	}
开发者ID:Potion,项目名称:Cinder-poScene,代码行数:56,代码来源:ViewController.cpp


示例4: keyDown

void XmlSettingsSetting::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getCode() == KeyEvent::KEY_x){
		if(mSettings){
			mSettings->toggleVisibility();
		}
	}
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:11,代码来源:xmlsettingssetting_app.cpp


示例5: onKeyDown

void PretzelRoot::onKeyDown(ci::app::KeyEvent &event)
{
    mGuiList[0]->keyDown( event.getChar(), event.getCode() );
    
//    for( auto it = mGuiList.begin(); it!=mGuiList.end(); ++it){
//        PretzelGui *pg = *it;
//        
//        if( pg->getGlobalBounds().contains( event.getPos() ) ){
//            (*it)->keyDown( event.getChar(), event.getCode() );
//        }
//    }
}
开发者ID:RallyTronics,项目名称:PretzelGui,代码行数:12,代码来源:PretzelRoot.cpp


示例6: keyDown

    // TODO: Fix this memory leak from new Link(...)
    bool ChatNode::keyDown(ci::app::KeyEvent event) {
        if (event.getCode() == ci::app::KeyEvent::KEY_RETURN) {
            if (active_node_identity_ != NULL && 
                active_node_identity_->object() != NULL) {
                // Finish updating by sending finished flag and deactivate
                ChatMessageNode::request_finish_update(*active_node_identity_, 
                    text_buffer_);

                active_node_ = NULL;
                text_buffer_.clear();
                active_node_identity_ = NULL;
            }
        } else {
            text_buffer_ += event.getChar();
            unsent_chars_ = true;

            if (active_node_identity_ == NULL) {
                // Request create a node, but make sure to update it
                TeteManager::instance() += ObjectController::instance()[id()];
                ID create_id_ = Utility::create_uuid();
                active_node_identity_ = Identity::create_identity(create_id_, NULL);

                LinkPtr user_link(new Link(&(Client::user_identity()),
                    LinkFlags(true, true, true)));
                
                std::deque<LinkPtr> temp_links;
                temp_links.push_back(user_link);

                if (!chat_messages_.empty()) {
                    const Identity* last_ident = Identity::get_identity_from_id(
                        chat_messages_.back()->id());
                    LinkPtr last_msg_link(new Link(last_ident, LinkFlags(true, true)));
                    temp_links.push_back(last_msg_link);
                }

                ChatMessageNode::request_create(create_id_,
                    *identity(), text_buffer_, temp_links);
            } else if (active_node_identity_ != NULL && 
                active_node_identity_->object() != NULL) {
                // Update the current node, and send an update request
                ChatMessageNode::request_update_text(*active_node_identity_,
                    text_buffer_);
                unsent_chars_ = false;
            }
        }

        return false;
    }
开发者ID:kourtin,项目名称:Atelier,代码行数:49,代码来源:chatNode.cpp


示例7: getIsBindedToModifier

bool Control::getIsBindedToModifier( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() && mKeyModifier == app::KeyEvent::META_DOWN )
    {
        return true;
    }
    else if ( event.isAltDown() && mKeyModifier == app::KeyEvent::ALT_DOWN )
    {
        return true;
    }
    else if( event.isControlDown() && mKeyModifier == app::KeyEvent::CTRL_DOWN )
    {
        return true;
    }
    return false;
}
开发者ID:SethGibson,项目名称:Cinder-UI,代码行数:16,代码来源:Control.cpp


示例8: keyDown

void XYPad::keyDown( ci::app::KeyEvent &event )
{
    if( event.isShiftDown() )
    {
        mStickyEnabled = true;
    }
}
开发者ID:SethGibson,项目名称:Cinder-UI,代码行数:7,代码来源:XYPad.cpp


示例9: keyDown

void ShadowMapSample::keyDown( ci::app::KeyEvent event )
{
	switch( event.getChar() ) {
		case ' ' :
			mPaused = ! mPaused;
		break;
		case 'r': { // create a random camera position
			vec3 eyeVec = Rand::randVec3f().normalized() * 6.0f;
			if( eyeVec.y < 0 ) eyeVec.y = -eyeVec.y;
			mCamera->lookAt( eyeVec, vec3(0,-2.5,0) );
			mLight->update( *mCamera );
		}
		break;
		case 'f':
			setFullScreen( ! isFullScreen() );
		break;
		case 'l': { // create a random light position
			vec3 lightPos = Rand::randVec3f().normalized() * 4.0f;
			if( lightPos.y < 0 ) lightPos.y = -lightPos.y;			
			mLight->lookAt( lightPos, vec3::zero() );
			mLight->update( *mCamera );
		}
		break;
		case 'c':
			mLookThroughCamera = ! mLookThroughCamera;
		break;
		case 'd':
			mDrawDepthMap = ! mDrawDepthMap;
		break;
	}
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:31,代码来源:main.cpp


示例10: keyDown

void GesturesDemo::keyDown(ci::app::KeyEvent event) {
  char key = event.getChar();
  if (key == 27) { //ESC
    exit(0);
  }
  else if (key == 'f') {
    setFullScreen(!isFullScreen());
  }
}
开发者ID:sjokoladevx,项目名称:Black-Nanocopter-Down---Final-Project-Repo,代码行数:9,代码来源:GesturesDemo.cpp


示例11: keyDown

void EditorState::keyDown(ci::app::KeyEvent event)
{
    // XXX duplicate raycast
    Vec2f pos = GG.mouse.getPos();
    Vec3f planeHit = GG.hexRender.raycastHexPlane(pos.x, pos.y);
    HexCoord selectedHex = GG.hexGrid.WorldToHex(planeHit);

    int keycode = event.getCode();

    Vec3f& cameraTo = GG.hexRender.getCameraTo();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_UP) {
        cameraTo += Vec3f(0, 2.0f, 0);
    }
    else if (keycode == app::KeyEvent::KEY_DOWN) {
        cameraTo += Vec3f(0, -2.0f, 0);
    }   
    else if (keycode == app::KeyEvent::KEY_LEFT) {
        cameraTo += Vec3f(-2.0f, 0, 0);
    }
    else if (keycode == app::KeyEvent::KEY_RIGHT) {
        cameraTo += Vec3f(2.0f, 0, 0);
    }
    else if (keycode == app::KeyEvent::KEY_g) {
        //  Generate hex colors
        Vec2i mapSize = GG.hexMap.getSize();
        for (int iy=0; iy < mapSize.y; ++iy) {
            for (int ix=0; ix < mapSize.x; ++ix) {
                HexCell& cell = GG.hexMap.at(HexCoord(ix, iy));
                if (cell.getLand()) {
                    int playerID = random.nextInt(0, 5);
                    cell.setOwner(playerID);
                    cell.setColor(GG.warGame.getPlayers()[playerID].getColor());
                }
            }
        }
    }
    else if (keycode == app::KeyEvent::KEY_DELETE) {
        GG.hexMap.at(selectedHex).setLand(0);
    }
    else if (keycode == app::KeyEvent::KEY_SPACE) {
        mManager.setActiveState(string("game"));
    }
    else if (keycode == app::KeyEvent::KEY_c) {
        vector<HexCoord> connected = GG.hexMap.connected(selectedHex);
        for (vector<HexCoord>::iterator it = connected.begin(); it != connected.end(); ++it) {
            HexCell& cell = GG.hexMap.at(*it);
            Color cellColor = cell.getColor();
            cellColor.r = 0.5f * cellColor.r;
            cellColor.g = 0.5f * cellColor.g;
            cellColor.b = 0.5f * cellColor.b;
            cell.setColor(cellColor);
        }
    }
}
开发者ID:safetydank,项目名称:netphyx,代码行数:57,代码来源:EditorState.cpp


示例12: ImGui_ImplCinder_KeyCallback

void ImGui_ImplCinder_KeyCallback(ci::app::KeyEvent e, bool isDown)
{
    ImGuiIO& io = ImGui::GetIO();
    
    io.KeysDown[e.getCode()] = isDown;

    io.KeyCtrl = io.KeysDown[ci::app::KeyEvent::KEY_LCTRL] || io.KeysDown[ci::app::KeyEvent::KEY_RCTRL];
    io.KeyShift = io.KeysDown[ci::app::KeyEvent::KEY_LSHIFT] || io.KeysDown[ci::app::KeyEvent::KEY_RSHIFT];
    io.KeyAlt = io.KeysDown[ci::app::KeyEvent::KEY_LALT] || io.KeysDown[ci::app::KeyEvent::KEY_RALT];
}
开发者ID:jrcurtis,项目名称:subsequencely,代码行数:10,代码来源:imgui_impl_cinder_gl3.cpp


示例13: keyDown

void https_example::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();

	} else if(event.getCode() == KeyEvent::KEY_v && event.isControlDown()){
		auto fileNameOrig = ds::Environment::getClipboard();
		mHttpsRequest.makeGetRequest("https://example.com", false, false);


	} else if(event.getCode() == KeyEvent::KEY_p){
		std::string datay = "{ \"data\": { \"type\": \"collection_links\", \"attributes\": { \"story_type\": \"Achievement\", \"story_id\": \"13\" }}}";
		std::vector<std::string> headers;
		headers.push_back("Accept: application/json");
		headers.push_back("Content-Type: application/json");
		mHttpsRequest.makePostRequest("https://example.com", datay, true, true, "", headers);

	// Shows all enabled sprites with a label for class type
	} else if(event.getCode() == KeyEvent::KEY_f){

		const int numRoots = mEngine.getRootCount();
		int numPlacemats = 0;
		for(int i = 0; i < numRoots - 1; i++){
			mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
				if(sprite.isEnabled()){
					sprite.setTransparent(false);
					sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
					sprite.setOpacity(0.95f);

					ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
					labelly->setText(typeid(sprite).name());
					labelly->enable(false);
					labelly->setColor(ci::Color::black());
				} else {

					ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
					if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
				}
			}, true);
		}
	}
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:43,代码来源:https_example_app.cpp


示例14: onKeyPress

//----------------------------------------------------------------------------------------------------------------------
void GAViz::onKeyPress(ci::app::KeyEvent e)
{
  const uint8_t numModes = 2;
  switch(e.getChar())
  {
  case 'n':
    m_mode = (m_mode + 1) % numModes;
    break;
  }
  
  NodeGroup::onKeyPress(e);
}
开发者ID:buhrmann,项目名称:dynmx,代码行数:13,代码来源:GAViz.cpp


示例15: keyDown

void redEyeApp::keyDown(ci::app::KeyEvent event) {
	if(event.getChar()=='i') {
        mHide= !mHide;
    } else if(event.getCode()==KeyEvent::KEY_ESCAPE) {
        setFullScreen(!isFullScreen());
    } else if(event.getChar()=='f') {
        fs::path path= getOpenFilePath(mPathFrag);
        if(!path.empty()) {
			mPathFrag= path;
            loadShader();
		}
    } else if(event.getChar()=='v') {
        fs::path path= getOpenFilePath(mPathVert);
		if(!path.empty()) {
			mPathVert= path;
            loadShader();
		}
    } else if(event.getChar()=='m') {
        mMode= (mMode+1)%9;
    }
}
开发者ID:redFrik,项目名称:redEye,代码行数:21,代码来源:redEyeApp.cpp


示例16: keyDown

void web_example::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);

	if(event.getChar() == KeyEvent::KEY_v && event.isControlDown()){
		auto clipboard = ds::Environment::getClipboard();
		if(!clipboard.empty() && mWebView){
			mWebView->setUrl(clipboard);
		}
	} else if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getChar() == KeyEvent::KEY_b){
		if(mWebView){
			mWebView->goBack();
		}
	} else if(event.getChar() == KeyEvent::KEY_f){
		if(mWebView){
			mWebView->goForward();
		}
	} else if(event.getChar() == KeyEvent::KEY_l){
		if(mWebView){
			mWebView->reload();
		}
	}
}
开发者ID:Downstream,项目名称:ds_cinder,代码行数:25,代码来源:web_example_app.cpp


示例17: keyDown

void ClientState::keyDown(ci::app::KeyEvent event)
{
    // Vec3f& cameraTo = GG.hexRender.getCameraTo();

    int keycode = event.getCode();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
        // XXX should push console to the top of the gui widget list
        GG.gui.attach(GG.console);
    }
}
开发者ID:safetydank,项目名称:netphyx,代码行数:13,代码来源:ClientState.cpp


示例18: getIsModifierDown

bool Control::getIsModifierDown( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() )
    {
        return true;
    }
    else if ( event.isAltDown() )
    {
        return true;
    }
    else if( event.isControlDown() )
    {
        return true;
    }
    else if( event.isShiftDown() )
    {
        return true;
    }
    else if( event.isAccelDown() )
    {
        return true;
    }
    return false;
}
开发者ID:SethGibson,项目名称:Cinder-UI,代码行数:24,代码来源:Control.cpp


示例19: keyDown

void ServerState::keyDown(ci::app::KeyEvent event)
{
    static int count = 0;
    ++count;

    // Vec3f& cameraTo = GG.hexRender.getCameraTo();
    io::stream<GuiConsoleStream> cout = GG.console->output();

    int keycode = event.getCode();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
        // XXX should push console to the top of the gui widget list
        GG.gui.attach(GG.console);
    }
    else if (keycode == app::KeyEvent::KEY_SPACE) {
        cout << "That's what I said: " << count << std::endl;
    }
}
开发者ID:safetydank,项目名称:Hexpad,代码行数:20,代码来源:ServerState.cpp


示例20: isBindedToKeyEvent

bool Control::isBindedToKeyEvent( ci::app::KeyEvent &event )
{
    bool useModifier = ( mKeyModifier != -1 ) ? true : false;
    bool modDown = getIsModifierDown( event );
    bool isBindedToMod = getIsBindedToModifier( event );
    bool isBindedToKey = getIsBindedToKey( event.getCode() );

    if( isBindedToKey )
    {
        if( isBindedToMod )
        {
            return true;
        }
        else if( !modDown && !useModifier )
        {
            return true;
        }
    }
    return false;
}
开发者ID:SethGibson,项目名称:Cinder-UI,代码行数:20,代码来源:Control.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ app::MouseEvent类代码示例发布时间:2022-05-31
下一篇:
C++ ci::CameraPersp类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap