本文整理汇总了C++中KeyEvent::getKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getKeyCode方法的具体用法?C++ KeyEvent::getKeyCode怎么用?C++ KeyEvent::getKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getKeyCode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(KeyEventTest, Properties) {
KeyEvent event;
// Initialize and get properties.
const nsecs_t ARBITRARY_DOWN_TIME = 1;
const nsecs_t ARBITRARY_EVENT_TIME = 2;
event.initialize(2, AINPUT_SOURCE_GAMEPAD, AKEY_EVENT_ACTION_DOWN,
AKEY_EVENT_FLAG_FROM_SYSTEM, AKEYCODE_BUTTON_X, 121,
AMETA_ALT_ON, 1, ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME);
ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event.getType());
ASSERT_EQ(2, event.getDeviceId());
ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_GAMEPAD), event.getSource());
ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, event.getAction());
ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, event.getFlags());
ASSERT_EQ(AKEYCODE_BUTTON_X, event.getKeyCode());
ASSERT_EQ(121, event.getScanCode());
ASSERT_EQ(AMETA_ALT_ON, event.getMetaState());
ASSERT_EQ(1, event.getRepeatCount());
ASSERT_EQ(ARBITRARY_DOWN_TIME, event.getDownTime());
ASSERT_EQ(ARBITRARY_EVENT_TIME, event.getEventTime());
// Set source.
event.setSource(AINPUT_SOURCE_JOYSTICK);
ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_JOYSTICK), event.getSource());
}
示例2: PublishAndConsumeKeyEvent
void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
status_t status;
const uint32_t seq = 15;
const int32_t deviceId = 1;
const int32_t source = AINPUT_SOURCE_KEYBOARD;
const int32_t action = AKEY_EVENT_ACTION_DOWN;
const int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM;
const int32_t keyCode = AKEYCODE_ENTER;
const int32_t scanCode = 13;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const int32_t repeatCount = 1;
const nsecs_t downTime = 3;
const nsecs_t eventTime = 4;
status = mPublisher->publishKeyEvent(seq, deviceId, source, action, flags,
keyCode, scanCode, metaState, repeatCount, downTime, eventTime);
ASSERT_EQ(OK, status)
<< "publisher publishKeyEvent should return OK";
uint32_t consumeSeq;
InputEvent* event;
status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event);
ASSERT_EQ(OK, status)
<< "consumer consume should return OK";
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType())
<< "consumer should have returned a key event";
KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
EXPECT_EQ(seq, consumeSeq);
EXPECT_EQ(deviceId, keyEvent->getDeviceId());
EXPECT_EQ(source, keyEvent->getSource());
EXPECT_EQ(action, keyEvent->getAction());
EXPECT_EQ(flags, keyEvent->getFlags());
EXPECT_EQ(keyCode, keyEvent->getKeyCode());
EXPECT_EQ(scanCode, keyEvent->getScanCode());
EXPECT_EQ(metaState, keyEvent->getMetaState());
EXPECT_EQ(repeatCount, keyEvent->getRepeatCount());
EXPECT_EQ(downTime, keyEvent->getDownTime());
EXPECT_EQ(eventTime, keyEvent->getEventTime());
status = mConsumer->sendFinishedSignal(seq, true);
ASSERT_EQ(OK, status)
<< "consumer sendFinishedSignal should return OK";
uint32_t finishedSeq = 0;
bool handled = false;
status = mPublisher->receiveFinishedSignal(&finishedSeq, &handled);
ASSERT_EQ(OK, status)
<< "publisher receiveFinishedSignal should return OK";
ASSERT_EQ(seq, finishedSeq)
<< "publisher receiveFinishedSignal should have returned the original sequence number";
ASSERT_TRUE(handled)
<< "publisher receiveFinishedSignal should have set handled to consumer's reply";
}
开发者ID:ishantvivek,项目名称:android_frameworks_native-temasek,代码行数:58,代码来源:InputPublisherAndConsumer_test.cpp
示例3:
void ComboBox::ItemWindow::onKeyReleased(const KeyEvent &e) {
uchar keycode = e.getKeyCode();
UIElement::onKeyReleased(e);
if(keycode == VK_ESC || keycode == VK_ENTER || keycode == VK_SPACE) {
if(keycode != VK_ESC)
_cb->setSelectedIndex(_highlighted);
closeImpl();
}
}
示例4: iterate
void ComboBox::ItemWindow::onKeyPressed(const KeyEvent &e) {
UIElement::onKeyReleased(e);
int oldhl = _highlighted;
_highlighted = iterate(e.getKeyCode(),_highlighted,_cb->_items.size());
if(oldhl != _highlighted) {
makeDirty(true);
repaint();
}
}
示例5: onKeyPressed
void ComboBox::onKeyPressed(const KeyEvent &e) {
UIElement::onKeyReleased(e);
int oldsel = _selected;
doSetIndex(iterate(e.getKeyCode(),_selected,_items.size()));
if(oldsel != _selected) {
makeDirty(true);
repaint();
}
}
示例6: onKeyDown
virtual void onKeyDown(KeyEvent &ev)
{
Frame::onKeyDown(ev);
// with ESC key you can close this application
if (ev.getKeyCode() == Keys::Escape) {
setVisible(false);
ev.consume();
}
}
示例7: onKeyUp
virtual void onKeyUp(KeyEvent& ev)
{
String mods;
if (ev.isShift() ) mods += L" Shift";
if (ev.isControl()) mods += L" Control";
if (ev.isAlt() ) mods += L" Alt";
m_console->println(format_string(L"onKeyUp(keyCode=%s, modifiers=%s, charCode=%d '%d')",
convert_to_string(ev.getKeyCode()), mods.c_str(),
ev.getCharCode(), ev.getCharCode()));
Widget::onKeyUp(ev);
}
示例8: onKeyPressed
void Editable::onKeyPressed(const KeyEvent &e) {
UIElement::onKeyPressed(e);
if(e.isPrintable())
insertAtCursor(e.getCharacter());
else {
size_t oldPos;
switch(e.getKeyCode()) {
case VK_DELETE:
removeNext();
break;
case VK_BACKSP:
removeLast();
break;
case VK_LEFT:
if(_cursor > 0)
moveCursor(-1);
if(e.isShiftDown())
changeSelection(_cursor,_cursor + 1,DIR_LEFT);
else if(_selStart != -1)
clearSelection();
break;
case VK_RIGHT:
if(_cursor < _str.length())
moveCursor(1);
if(e.isShiftDown())
changeSelection(_cursor,_cursor - 1,DIR_RIGHT);
else if(_selStart != -1)
clearSelection();
break;
case VK_HOME:
oldPos = _cursor;
if(_cursor != 0)
moveCursorTo(0);
if(e.isShiftDown())
changeSelection(_cursor,oldPos,DIR_LEFT);
else if(_selStart != -1)
clearSelection();
break;
case VK_END:
oldPos = _cursor;
if(_cursor != _str.length())
moveCursorTo(_str.length());
if(e.isShiftDown())
changeSelection(_cursor,oldPos,DIR_RIGHT);
else if(_selStart != -1)
clearSelection();
break;
}
}
repaint();
}
示例9: keyReleased
//-------------------------------------------------------------------------------
KeyEventResult MyGUIInput::keyReleased( const KeyEvent& _evt )
{
MyGUI::Widget* focusWidget = MyGUI::InputManager::getInstance().getKeyFocusWidget();
if(focusWidget && canWidgetProcessKeys(focusWidget))
{
if(MyGUI::InputManager::getInstance().injectKeyRelease(
MyGUIInputConv::keyCodeToMyGUI(_evt.getKeyCode())))
return KeyEventResult::PROCESSED;
}
if(MyGUI::InputManager::getInstance().isModalAny())
return KeyEventResult::PROCESSED;
return KeyEventResult::NOT_PROCESSED;
}
示例10: PublishAndConsumeKeyEvent
void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
status_t status;
const int32_t deviceId = 1;
const int32_t source = AINPUT_SOURCE_KEYBOARD;
const int32_t action = AKEY_EVENT_ACTION_DOWN;
const int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM;
const int32_t keyCode = AKEYCODE_ENTER;
const int32_t scanCode = 13;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const int32_t repeatCount = 1;
const nsecs_t downTime = 3;
const nsecs_t eventTime = 4;
status = mPublisher->publishKeyEvent(deviceId, source, action, flags,
keyCode, scanCode, metaState, repeatCount, downTime, eventTime);
ASSERT_EQ(OK, status)
<< "publisher publishKeyEvent should return OK";
status = mPublisher->sendDispatchSignal();
ASSERT_EQ(OK, status)
<< "publisher sendDispatchSignal should return OK";
status = mConsumer->receiveDispatchSignal();
ASSERT_EQ(OK, status)
<< "consumer receiveDispatchSignal should return OK";
InputEvent* event;
status = mConsumer->consume(& mEventFactory, & event);
ASSERT_EQ(OK, status)
<< "consumer consume should return OK";
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType())
<< "consumer should have returned a key event";
KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
EXPECT_EQ(deviceId, keyEvent->getDeviceId());
EXPECT_EQ(source, keyEvent->getSource());
EXPECT_EQ(action, keyEvent->getAction());
EXPECT_EQ(flags, keyEvent->getFlags());
EXPECT_EQ(keyCode, keyEvent->getKeyCode());
EXPECT_EQ(scanCode, keyEvent->getScanCode());
EXPECT_EQ(metaState, keyEvent->getMetaState());
EXPECT_EQ(repeatCount, keyEvent->getRepeatCount());
EXPECT_EQ(downTime, keyEvent->getDownTime());
EXPECT_EQ(eventTime, keyEvent->getEventTime());
status = mConsumer->sendFinishedSignal();
ASSERT_EQ(OK, status)
<< "consumer sendFinishedSignal should return OK";
status = mPublisher->receiveFinishedSignal();
ASSERT_EQ(OK, status)
<< "publisher receiveFinishedSignal should return OK";
status = mPublisher->reset();
ASSERT_EQ(OK, status)
<< "publisher reset should return OK";
}
示例11: onKeyReleased
void ComboBox::onKeyReleased(const KeyEvent &e) {
uchar keycode = e.getKeyCode();
UIElement::onKeyReleased(e);
if(keycode == VK_ENTER || keycode == VK_SPACE)
showPopup();
}