本文整理汇总了C++中gcn::KeyEvent::isShiftPressed方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::isShiftPressed方法的具体用法?C++ KeyEvent::isShiftPressed怎么用?C++ KeyEvent::isShiftPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::isShiftPressed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
// -- KeyListener notifications
void ListBox::keyPressed(gcn::KeyEvent& keyEvent)
{
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
{
if (keyEvent.isShiftPressed())
{
const std::string actionEventId = getActionEventId();
setActionEventId("default");
distributeActionEvent();
setActionEventId(actionEventId);
}
else
distributeActionEvent();
}
else if (key.getValue() == Key::UP)
decrementSelected();
else if (key.getValue() == Key::DOWN)
incrementSelected();
else if (key.getValue() == Key::HOME)
setSelected(0);
else if (key.getValue() == Key::END)
setSelected(getListModel()->getNumberOfElements() - 1);
else
return;
keyEvent.consume();
}
示例2: keyPressed
void ItemContainer::keyPressed(gcn::KeyEvent &event)
{
const int columns = std::max(1, getWidth() / gridWidth);
const int gridSlot = getVisibleSlot(getSelectedItem());
int itemX = gridSlot % columns;
int itemY = gridSlot / columns;
// Handling direction keys: all of these set selectNewItem, and change
// itemX or itemY checking only that the selection doesn't go off the top,
// left or right of the grid. The block below the switch statement then
// checks that there's an item in that slot (implictly bounds-checking that
// the selection didn't go off the bottom of the grid).
bool selectNewItem = false;
switch (event.getKey().getValue())
{
case Key::LEFT:
if (itemX != 0)
itemX--;
selectNewItem = true;
event.consume();
break;
case Key::RIGHT:
if (itemX < (columns - 1))
itemX++;
selectNewItem = true;
event.consume();
break;
case Key::UP:
if (itemY != 0)
itemY--;
selectNewItem = true;
event.consume();
break;
case Key::DOWN:
itemY++;
selectNewItem = true;
event.consume();
break;
case Key::ENTER:
case Key::SPACE:
if (event.isShiftPressed())
{
const std::string actionEventId = getActionEventId();
setActionEventId("default");
distributeActionEvent();
setActionEventId(actionEventId);
}
else
distributeActionEvent();
event.consume();
break;
}
if (selectNewItem)
{
Item* selection = getItemInVisibleSlot(itemX + columns * itemY);
if (selection)
setSelectedItemIndex(selection->getInvIndex());
}
}