本文整理汇总了C++中KeyboardEvent::consume方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardEvent::consume方法的具体用法?C++ KeyboardEvent::consume怎么用?C++ KeyboardEvent::consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyboardEvent
的用法示例。
在下文中一共展示了KeyboardEvent::consume方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onChar
void OsuScreenBackable::onChar(KeyboardEvent &e)
{
if (!m_bVisible) return;
e.consume();
}
示例3: onKeyDown
//.........这里部分代码省略.........
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();
}
if (m_selectedButton != NULL && e == KEY_ENTER)
m_selectedButton->click();
}
// consume ALL events, except for a few special binds which are allowed through (e.g. for unpause or changing the local offset in Osu.cpp)
if (e != KEY_ESCAPE && e != (KEYCODE)OsuKeyBindings::GAME_PAUSE.getInt() && e != (KEYCODE)OsuKeyBindings::INCREASE_LOCAL_OFFSET.getInt() && e != (KEYCODE)OsuKeyBindings::DECREASE_LOCAL_OFFSET.getInt())
e.consume();
}
示例4: onChar
void OsuPauseMenu::onChar(KeyboardEvent &e)
{
if (!m_bVisible) return;
e.consume();
}
示例5: onKeyDown
void OsuPauseMenu::onKeyDown(KeyboardEvent &e)
{
if (!m_bVisible) return;
if (e == KEY_1)
onContinueClicked();
else if (e == KEY_2)
onRetryClicked();
else if (e == KEY_3)
onBackClicked();
else if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() || e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt())
{
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)
{
OsuPauseMenuButton *nextSelectedButton = m_buttons[0];
bool next = false;
for (int i=0; i<m_buttons.size(); i++)
{
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)
{
OsuPauseMenuButton *nextSelectedButton = m_buttons[m_buttons.size()-1];
bool next = false;
for (int i=m_buttons.size()-1; i>=0; i--)
{
if (next)
{
nextSelectedButton = m_buttons[i];
break;
}
if (m_selectedButton == m_buttons[i])
next = true;
}
m_selectedButton = nextSelectedButton;
onSelectionChange();
}
if (m_selectedButton != NULL && e == KEY_ENTER)
m_selectedButton->click();
}
if (e != KEY_ESCAPE && e != (KEYCODE)OsuKeyBindings::GAME_PAUSE.getInt()) // needed for unpause in Osu.cpp
e.consume();
}