本文整理汇总了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;
}
//.........这里部分代码省略.........