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


C++ Editbox::setCaratIndex方法代码示例

本文整理汇总了C++中cegui::Editbox::setCaratIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Editbox::setCaratIndex方法的具体用法?C++ Editbox::setCaratIndex怎么用?C++ Editbox::setCaratIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cegui::Editbox的用法示例。


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

示例1: ValidateNAMEIP

	void MenuState::ValidateNAMEIP()
	{
		// This shouldn't be here!!!
		// Socket needs to be closed/reset before IO_Service is reset.
		if(LC::Client::getSingletonPtr()->socket_)
		{
			boost::shared_ptr<tcp::socket> sockets;
			sockets = LC::Client::getSingletonPtr()->socket_;
			boost::system::error_code error;
			sockets->shutdown(boost::asio::socket_base::shutdown_both, error);
			sockets->close(error);
		}
		LC::Client::getSingletonPtr()->socket_.reset();
		
		// May be overly drastic.
		TheApplication.ResetIOService();

		if(m_IsHost)
		{
			// Create Server.
			std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str();
			Server::getSingletonPtr()->reset(TheApplication.getIOService(), userName);

			// Create Client.
			// Need better way of doing this.
			tcp::resolver resolver(*TheApplication.getIOService());
			std::ostringstream ss;
			int portnumber = TheApplication.getPortNumber();
			ss << portnumber;
			tcp::resolver::query query("127.0.0.1", ss.str().c_str());
			tcp::resolver::iterator iterator = resolver.resolve(query);
			Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName);
			
			wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: SERVER");
			wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText("");
			wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->setText("");
		}
		else
		{
			std::string text = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText().c_str();

			// Check for valid IP address.
			boost::system::error_code ec;
			boost::asio::ip::address address = boost::asio::ip::address::from_string(text, ec);

			std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str();

			if(!ec && userName.length()>=1)
			{
				CEGUI::String IPAddress = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText();

				// Need better way of doing this.
				tcp::resolver resolver(*TheApplication.getIOService());
				std::ostringstream ss;
				int portnumber = TheApplication.getPortNumber();
				ss << portnumber;
				tcp::resolver::query query(IPAddress.c_str(), ss.str().c_str());
				tcp::resolver::iterator iterator = resolver.resolve(query);
				Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName);

				wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: " + address.to_string());
			}
			else if(ec)
			{
				wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText("Invalid Address");
				CEGUI::Editbox *editBox = static_cast<CEGUI::Editbox*>(wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox"));
				editBox->setCaratIndex(editBox->getText().length());
			}
		}
	}
开发者ID:Grogist,项目名称:LightCycle,代码行数:70,代码来源:MenuState.cpp

示例2: HandleEnterKey


//.........这里部分代码省略.........
		if(we.scancode == CEGUI::Key::ArrowDown)
		{
			if(_itltext != _lasttexts.end())
			{
				if(_itltext != _lasttexts.begin())
					--_itltext;
				else
					_itltext = _lasttexts.end();
			}

			if(_itltext != _lasttexts.end())
			{
				CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(
													(const unsigned char *)_itltext->c_str());
			}
			else
			{
				CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText("");
			}

			return true;
		}


		if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown)
			return true;



		// paste text
		if(we.scancode == CEGUI::Key::V && _control_key_on)
		{
			CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
				(CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"));
			if(bed->isActive())
			{
				if(_text_copyed != "")
				{
					size_t selB = bed->getSelectionStartIndex();
					size_t selE = bed->getSelectionLength();
					CEGUI::String str = bed->getText();
					if(selE > 0)
					{
						str = str.erase(selB, selE);
					}

					if(str.size() + _text_copyed.size() < bed->getMaxTextLength())
					{
						size_t idx = bed->getCaratIndex();
						str = str.insert(idx, (unsigned char *)_text_copyed.c_str());
						bed->setText(str);
						bed->setCaratIndex(idx + _text_copyed.size());
					}
				}

				return true;
			}
		}
	}



	// copy text
	if(we.scancode == CEGUI::Key::C && _control_key_on)
	{
		CEGUI::Window * actw = _myChat->getActiveChild();
		if(actw != NULL)
		{
			if(actw->getName() == "Chat/edit")
			{
				CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw);
				size_t selB = bed->getSelectionStartIndex();
				size_t selE = bed->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = bed->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
			else
			{
				CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw);
				size_t selB = txt->getSelectionStartIndex();
				size_t selE = txt->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = txt->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
		}

	}

    return false;
}
开发者ID:leloulight,项目名称:lbanet,代码行数:101,代码来源:ChatBox.cpp

示例3: GUI_Paste_From_Clipboard

bool GUI_Paste_From_Clipboard( void )
{
	CEGUI::Window *sheet = CEGUI::System::getSingleton().getGUISheet();

	// no sheet
	if( !sheet )
	{
		return 0;
	}

	CEGUI::Window *window_active = sheet->getActiveChild();

	// no active window
	if( !window_active )
	{
		return 0;
	}

	const CEGUI::String &type = window_active->getType();

	// MultiLineEditbox
	if( type.find( "/MultiLineEditbox" ) != CEGUI::String::npos )
	{
		CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox*>(window_active);

		if( editbox->isReadOnly() )
		{
			return 0;
		}

		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();

		CEGUI::String new_text = editbox->getText();
		// erase selected text
		new_text.erase( beg, len );

		// get clipboard text
		CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
		// set new text
		editbox->setText( new_text.insert( beg, clipboard_text ) );
		// set new carat index
		editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
	}
	// Editbox
	else if( type.find( "/Editbox" ) != CEGUI::String::npos )
	{
		CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox*>(window_active);

		if( editbox->isReadOnly() )
		{
			return 0;
		}

		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();

		CEGUI::String new_text = editbox->getText();
		// erase selected text
		new_text.erase( beg, len );

		// get clipboard text
		CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
		// set new text
		editbox->setText( new_text.insert( beg, clipboard_text ) );
		// set new carat index
		editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
	}
	else
	{
		return 0;
	}

	return 1;
}
开发者ID:projectskillz,项目名称:SMC,代码行数:75,代码来源:generic.cpp


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