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


C++ KeyEvent::character方法代码示例

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


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

示例1: processKeyEvent

/**
 *	This method processes key down events
 */
LineEditor::ProcessState LineEditor::processKeyEvent(
	KeyEvent event, std::string& resultString )
{
	#define EMPTY_STR(str) \
		(str.empty() || str.find_first_not_of(32) == std::string::npos)

	const KeyEvent::Key eventKey = event.key();

	bool isResultSet = false;
	bool isHandled = false;

	if (event.isKeyDown())
	{
		char keyChar = event.character();

		isHandled = this->processAdvanceEditKeys( event );
		if (!isHandled)
		{
			isHandled = true;
			switch (eventKey)
			{
			case KeyEvent::KEY_RETURN:
			case KeyEvent::KEY_JOY8:	// 'A' key
				if (!event.isAltDown())
				{
					resultString = editString_;
					isResultSet = true;
					editString_ = "";
					cx_ = 0;
					lastChar_ = 0;
				}
				else
				{
					isHandled = false;
				}
				break;

			case KeyEvent::KEY_DELETE:
				if ( cx_ < (int)editString_.length( ) )
					deleteChar( cx_ );
				break;

			case KeyEvent::KEY_BACKSPACE:
			case KeyEvent::KEY_JOY14:	// left trigger
				if ( cx_ )
				{
					cx_--;
					deleteChar( cx_ );
				}
				break;

			case KeyEvent::KEY_INSERT:
				inOverwriteMode_ = !inOverwriteMode_;
				break;

			case KeyEvent::KEY_LEFTARROW:
			case KeyEvent::KEY_JOY2:	// dpad left
				if ( cx_ > 0 )
					cx_--;
				break;

			case KeyEvent::KEY_RIGHTARROW:
			case KeyEvent::KEY_JOY3:	// dpad right
				if ( cx_ < (int)editString_.length() )
					cx_++;
				break;

			case KeyEvent::KEY_UPARROW:
			case KeyEvent::KEY_JOY0:	// dpad up
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = 1;
					}
					else 
					{
						if (!EMPTY_STR(editString_))
						{
							history_[historyShown_] = editString_;
						}
						++historyShown_;
					}
					showHistory();
				}
				break;

			case KeyEvent::KEY_DOWNARROW:
			case KeyEvent::KEY_JOY1:	// dpad down
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = history_.size() - 1;
					}
//.........这里部分代码省略.........
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:101,代码来源:lineeditor.cpp


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