本文整理汇总了C++中KeyboardEvent::isConsumed方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardEvent::isConsumed方法的具体用法?C++ KeyboardEvent::isConsumed怎么用?C++ KeyboardEvent::isConsumed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyboardEvent
的用法示例。
在下文中一共展示了KeyboardEvent::isConsumed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onKeyDown
void OsuScreenBackable::onKeyDown(KeyboardEvent &e)
{
OsuScreen::onKeyDown(e);
if (!m_bVisible || e.isConsumed()) return;
if (e == KEY_ESCAPE || e == (KEYCODE)OsuKeyBindings::GAME_PAUSE.getInt())
onBack();
e.consume();
}
示例2: onKeyDown
void OsuPauseMenu::onKeyDown(KeyboardEvent &e)
{
OsuScreen::onKeyDown(e); // only used for options menu
if (!m_bVisible || e.isConsumed()) return;
if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() || e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt())
{
bool fireButtonClick = false;
if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() && !m_bClick1Down)
{
m_bClick1Down = true;
fireButtonClick = true;
}
if (e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt() && !m_bClick2Down)
{
m_bClick2Down = true;
fireButtonClick = true;
}
if (fireButtonClick)
{
for (int i=0; i<m_buttons.size(); i++)
{
if (m_buttons[i]->isMouseInside())
{
m_buttons[i]->click();
break;
}
}
}
}
// handle arrow keys selection
if (m_buttons.size() > 0)
{
if (!engine->getKeyboard()->isAltDown() && e == KEY_DOWN)
{
OsuUIPauseMenuButton *nextSelectedButton = m_buttons[0];
// get first visible button
for (int i=0; i<m_buttons.size(); i++)
{
if (!m_buttons[i]->isVisible())
continue;
nextSelectedButton = m_buttons[i];
break;
}
// next selection logic
bool next = false;
for (int i=0; i<m_buttons.size(); i++)
{
if (!m_buttons[i]->isVisible())
continue;
if (next)
{
nextSelectedButton = m_buttons[i];
break;
}
if (m_selectedButton == m_buttons[i])
next = true;
}
m_selectedButton = nextSelectedButton;
onSelectionChange();
}
if (!engine->getKeyboard()->isAltDown() && e == KEY_UP)
{
OsuUIPauseMenuButton *nextSelectedButton = m_buttons[m_buttons.size()-1];
// get first visible button
for (int i=m_buttons.size()-1; i>=0; i--)
{
if (!m_buttons[i]->isVisible())
continue;
nextSelectedButton = m_buttons[i];
break;
}
// next selection logic
bool next = false;
for (int i=m_buttons.size()-1; i>=0; i--)
{
if (!m_buttons[i]->isVisible())
continue;
if (next)
{
nextSelectedButton = m_buttons[i];
break;
}
if (m_selectedButton == m_buttons[i])
next = true;
}
m_selectedButton = nextSelectedButton;
onSelectionChange();
}
//.........这里部分代码省略.........