本文整理汇总了C++中gcn::KeyEvent::consume方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::consume方法的具体用法?C++ KeyEvent::consume怎么用?C++ KeyEvent::consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed() || !isFocused())
return;
if (keyEvent.getKey().getValue() == Key::LEFT)
{
int index = getSelectedTabIndex();
index--;
if (index < 0)
setSelectedTab(mTabs[mTabs.size() - 1].first);
else
setSelectedTab(mTabs[index].first);
keyEvent.consume();
}
else if (keyEvent.getKey().getValue() == Key::RIGHT)
{
int index = getSelectedTabIndex();
index++;
if (index >= (int) mTabs.size())
setSelectedTab(mTabs[0].first);
else
setSelectedTab(mTabs[index].first);
keyEvent.consume();
}
}
示例2: keyPressed
void Slider::keyPressed(gcn::KeyEvent &keyEvent)
{
gcn::Key key = keyEvent.getKey();
if (getOrientation() == HORIZONTAL)
{
if (key.getValue() == Key::RIGHT)
{
setValue(getValue() + getStepLength());
distributeActionEvent();
keyEvent.consume();
}
else if (key.getValue() == Key::LEFT)
{
setValue(getValue() - getStepLength());
distributeActionEvent();
keyEvent.consume();
}
}
else
{
if (key.getValue() == Key::UP)
{
setValue(getValue() + getStepLength());
distributeActionEvent();
keyEvent.consume();
}
else if (key.getValue() == Key::DOWN)
{
setValue(getValue() - getStepLength());
distributeActionEvent();
keyEvent.consume();
}
}
}
示例3: keyPressed
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed() || !isFocused())
return;
if (keyEvent.getKey().getValue() == Key::LEFT)
{
TabContainer::iterator index = getTabIterator(mSelectedTab);
if (index != mTabs.begin())
setSelectedTab((--index)->first);
else
setSelectedTab((--mTabs.end())->first);
keyEvent.consume();
}
else if (keyEvent.getKey().getValue() == Key::RIGHT)
{
TabContainer::iterator index = getTabIterator(mSelectedTab);
if (index != (--mTabs.end()))
setSelectedTab((++index)->first);
else
setSelectedTab(mTabs.begin()->first);
keyEvent.consume();
}
}
示例4: keyPressed
void Menu::keyPressed(gcn::KeyEvent& keyEvent) {
std::cout << "Menu::keyPressed" << std::endl;
hikari::Input::Button button =
InputHelper::getMappedButtonForKey(keyEvent.getKey());
if(button == Input::BUTTON_UP) {
selectPreviousItem();
keyEvent.consume();
} else if(button == Input::BUTTON_DOWN) {
selectNextItem();
keyEvent.consume();
} else if(button == Input::BUTTON_START || button == Input::BUTTON_SHOOT) {
distributeActionEvent();
}
}
示例5: keyPressed
void IntTextField::keyPressed(gcn::KeyEvent &event)
{
int action = static_cast<KeyEvent*>(&event)->getActionId();
if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE)
{
setText(std::string());
if (mSendAlwaysEvents)
distributeActionEvent();
event.consume();
}
if (!event.getKey().isNumber())
return;
TextField::keyPressed(event);
std::istringstream s(getText());
int i;
s >> i;
setValue(i);
if (mSendAlwaysEvents)
distributeActionEvent();
}
示例6: keyPressed
void PlayControllerZone::keyPressed( gcn::KeyEvent& keyEvent )
{
switch ( keyEvent.getKey().getValue() )
{
case gcn::Key::LEFT:
view().Scroll( 1,
IMap::WEST );
break;
case gcn::Key::RIGHT:
view().Scroll( 1,
IMap::EAST );
break;
case gcn::Key::UP:
view().Scroll( 1,
IMap::NORTH );
break;
case gcn::Key::DOWN:
view().Scroll( 1,
IMap::SOUTH );
break;
default:
;
}
keyEvent.consume();
}
示例7: 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();
}
示例8: keyPressed
void IntroController::keyPressed( gcn::KeyEvent& keyEvent )
{
if ( keyEvent.getKey().getValue() == gcn::Key::ESCAPE ) {
model().final(); //! Paramos el bucle asi?.......
keyEvent.consume();
}
示例9: keyPressed
void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
action(gcn::ActionEvent(mCancelButton,
mCancelButton->getActionEventId()));
break;
default:
break;
}
}
示例10: keyPressed
void IntTextField::keyPressed(gcn::KeyEvent &event)
{
const gcn::Key &key = event.getKey();
if (key.getValue() == Key::BACKSPACE ||
key.getValue() == Key::DELETE)
{
setText(std::string());
event.consume();
}
if (!key.isNumber())
return;
TextField::keyPressed(event);
std::istringstream s(getText());
int i;
s >> i;
setValue(i);
}
示例11: keyPressed
// -- KeyListener notifications
void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed())
return;
int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
switch (actionId)
{
case Input::KEY_GUI_SELECT:
case Input::KEY_GUI_SELECT2:
dropDown();
break;
case Input::KEY_GUI_UP:
setSelected(getSelected() - 1);
break;
case Input::KEY_GUI_DOWN:
setSelected(getSelected() + 1);
break;
case Input::KEY_GUI_HOME:
setSelected(0);
break;
case Input::KEY_GUI_END:
if (mListBox->getListModel())
{
setSelected(mListBox->getListModel()->
getNumberOfElements() - 1);
}
break;
default:
return;
}
keyEvent.consume();
}
示例12: keyPressed
// -- KeyListener notifications
void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
{
distributeActionEvent();
keyEvent.consume();
}
else if (key.getValue() == Key::UP)
{
setSelectedRow(mSelectedRow - 1);
keyEvent.consume();
}
else if (key.getValue() == Key::DOWN)
{
setSelectedRow(mSelectedRow + 1);
keyEvent.consume();
}
else if (key.getValue() == Key::LEFT)
{
setSelectedColumn(mSelectedColumn - 1);
keyEvent.consume();
}
else if (key.getValue() == Key::RIGHT)
{
setSelectedColumn(mSelectedColumn + 1);
keyEvent.consume();
}
else if (key.getValue() == Key::HOME)
{
setSelectedRow(0);
setSelectedColumn(0);
keyEvent.consume();
}
else if (key.getValue() == Key::END)
{
setSelectedRow(mModel->getRows() - 1);
setSelectedColumn(mModel->getColumns() - 1);
keyEvent.consume();
}
}
示例13: keyPressed
// -- KeyListener notifications
void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
{
if (keyEvent.isConsumed())
return;
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
dropDown();
else if (key.getValue() == Key::UP)
setSelected(getSelected() - 1);
else if (key.getValue() == Key::DOWN)
setSelected(getSelected() + 1);
else if (key.getValue() == Key::HOME)
setSelected(0);
else if (key.getValue() == Key::END)
setSelected(mListBox->getListModel()->getNumberOfElements() - 1);
else
return;
keyEvent.consume();
}
示例14: keyPressed
//.........这里部分代码省略.........
++mCaretRow;
mCaretColumn = 0;
}
break;
}
case Input::KEY_GUI_BACKSPACE:
{
if (mCaretColumn != 0 && mEditable)
{
mTextRows[mCaretRow].erase(mCaretColumn - 1, 1);
--mCaretColumn;
}
else if (mCaretColumn == 0 && mCaretRow != 0 && mEditable)
{
mCaretColumn = mTextRows[mCaretRow - 1].size();
mTextRows[mCaretRow - 1] += mTextRows[mCaretRow];
mTextRows.erase(mTextRows.begin() + mCaretRow);
--mCaretRow;
}
break;
}
case Input::KEY_GUI_DELETE:
{
if (mCaretColumn < static_cast<int>(
mTextRows[mCaretRow].size()) && mEditable)
{
mTextRows[mCaretRow].erase(mCaretColumn, 1);
}
else if (mCaretColumn == static_cast<int>(
mTextRows[mCaretRow].size()) &&
mCaretRow < (static_cast<int>(mTextRows.size()) - 1) &&
mEditable)
{
mTextRows[mCaretRow] += mTextRows[mCaretRow + 1];
mTextRows.erase(mTextRows.begin() + mCaretRow + 1);
}
break;
}
case Input::KEY_GUI_PAGE_UP:
{
gcn::Widget* par = getParent();
if (par)
{
int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
mCaretRow -= rowsPerPage;
if (mCaretRow < 0)
mCaretRow = 0;
}
break;
}
case Input::KEY_GUI_PAGE_DOWN:
{
gcn::Widget* par = getParent();
if (par)
{
int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
mCaretRow += rowsPerPage;
if (mCaretRow >= static_cast<int>(mTextRows.size()))
mCaretRow = mTextRows.size() - 1;
}
break;
}
case Input::KEY_GUI_TAB:
{
if (mEditable)
{
mTextRows[mCaretRow].insert(mCaretColumn, std::string(" "));
mCaretColumn += 4;
}
break;
}
default:
{
if (key.isCharacter() && mEditable)
{
mTextRows[mCaretRow].insert(mCaretColumn,
std::string(1, static_cast<char>(key.getValue())));
++ mCaretColumn;
}
break;
}
}
adjustSize();
scrollToCaret();
keyEvent.consume();
}
示例15: keyPressed
void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
action(gcn::ActionEvent(mSwitchLoginButton,
mSwitchLoginButton->getActionEventId()));
break;
case Input::KEY_GUI_RIGHT:
{
keyEvent.consume();
int idx;
int idx2;
if (getFocusedContainer(idx, idx2))
{
idx ++;
if (idx == SLOTS_PER_ROW)
break;
setFocusedContainer(idx, idx2);
}
break;
}
case Input::KEY_GUI_LEFT:
{
keyEvent.consume();
int idx;
int idx2;
if (getFocusedContainer(idx, idx2))
{
if (!idx || idx == SLOTS_PER_ROW)
break;
idx --;
setFocusedContainer(idx, idx2);
}
break;
}
case Input::KEY_GUI_UP:
{
keyEvent.consume();
int idx;
int idx2;
if (getFocusedContainer(idx, idx2))
{
if (idx < SLOTS_PER_ROW && !idx2)
break;
if (idx2 > 0)
{
idx2 = 0;
}
else
{
idx -= SLOTS_PER_ROW;
if (mCharacterEntries[idx]->getCharacter())
idx2 = 1;
else
idx2 = 0;
}
setFocusedContainer(idx, idx2);
}
break;
}
case Input::KEY_GUI_DOWN:
{
keyEvent.consume();
int idx;
int idx2;
if (getFocusedContainer(idx, idx2))
{
if (idx >= SLOTS_PER_ROW && idx2)
break;
if (idx2 > 0)
{
idx += SLOTS_PER_ROW;
idx2 = 0;
}
else
{
if (mCharacterEntries[idx]->getCharacter())
idx2 = 1;
else
idx += SLOTS_PER_ROW;
}
setFocusedContainer(idx, idx2);
}
break;
}
case Input::KEY_GUI_DELETE:
{
keyEvent.consume();
int idx;
int idx2;
if (getFocusedContainer(idx, idx2)
&& mCharacterEntries[idx]->getCharacter())
//.........这里部分代码省略.........