本文整理汇总了C++中KeyEvent::getActionId方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getActionId方法的具体用法?C++ KeyEvent::getActionId怎么用?C++ KeyEvent::getActionId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getActionId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
void QuitDialog::keyPressed(KeyEvent &event)
{
const int actionId = event.getActionId();
int dir = 0;
switch (actionId)
{
case InputAction::GUI_SELECT:
case InputAction::GUI_SELECT2:
action(ActionEvent(nullptr, mOkButton->getActionEventId()));
break;
case InputAction::GUI_CANCEL:
action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
break;
case InputAction::GUI_UP:
dir = -1;
break;
case InputAction::GUI_DOWN:
dir = 1;
break;
default:
break;
}
if (dir != 0)
{
std::vector<RadioButton*>::const_iterator it = mOptions.begin();
const std::vector<RadioButton*>::const_iterator
it_end = mOptions.end();
for (; it < it_end; ++it)
{
if ((*it)->isSelected())
break;
}
if (it == mOptions.end())
{
if (mOptions[0])
mOptions[0]->setSelected(true);
return;
}
else if (it == mOptions.begin() && dir < 0)
{
it = mOptions.end();
}
it += dir;
if (it == mOptions.end())
it = mOptions.begin();
(*it)->setSelected(true);
}
}
示例2: keyPressed
void ServerDialog::keyPressed(KeyEvent &event)
{
switch (event.getActionId())
{
case InputAction::GUI_CANCEL:
event.consume();
client->setState(STATE_EXIT);
return;
case InputAction::GUI_SELECT:
case InputAction::GUI_SELECT2:
event.consume();
action(ActionEvent(nullptr,
mConnectButton->getActionEventId()));
return;
case InputAction::GUI_INSERT:
(new EditServerDialog(this, ServerInfo(), -1))->postInit();
return;
case InputAction::GUI_DELETE:
{
const int index = mServersList->getSelected();
if (index >= 0)
{
mServersList->setSelected(0);
mServers.erase(mServers.begin() + index);
saveCustomServers();
}
return;
}
case InputAction::GUI_BACKSPACE:
{
const int index = mServersList->getSelected();
if (index >= 0)
{
(new EditServerDialog(this, mServers.at(index),
index))->postInit();
}
return;
}
default:
break;
}
if (!event.isConsumed())
mServersList->keyPressed(event);
}
示例3: keyPressed
void CharCreateDialog::keyPressed(KeyEvent &event)
{
const InputActionT actionId = event.getActionId();
switch (actionId)
{
case InputAction::GUI_CANCEL:
event.consume();
action(ActionEvent(mCancelButton,
mCancelButton->getActionEventId()));
break;
default:
break;
}
}
示例4: keyPressed
void WorldSelectDialog::keyPressed(KeyEvent &event)
{
const int actionId = event.getActionId();
if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
{
action(ActionEvent(nullptr,
mChangeLoginButton->getActionEventId()));
}
else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
|| actionId == static_cast<int>(InputAction::GUI_SELECT2))
{
action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
}
}
示例5: keyPressed
void EditServerDialog::keyPressed(KeyEvent &event)
{
if (event.isConsumed())
return;
const InputActionT actionId = event.getActionId();
if (actionId == InputAction::GUI_CANCEL)
{
scheduleDelete();
}
else if (actionId == InputAction::GUI_SELECT ||
actionId == InputAction::GUI_SELECT2)
{
action(ActionEvent(nullptr, mOkButton->getActionEventId()));
}
}
示例6: keyPressed
void ListBox::keyPressed(KeyEvent &event)
{
const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
distributeActionEvent();
event.consume();
}
else if (action == InputAction::GUI_UP)
{
if (mSelected > 0)
{
setSelected(mSelected - 1);
}
else if (mSelected == 0 &&
mWrappingEnabled &&
getListModel() != nullptr)
{
setSelected(getListModel()->getNumberOfElements() - 1);
}
event.consume();
}
else if (action == InputAction::GUI_DOWN)
{
const int num = getListModel()->getNumberOfElements() - 1;
if (mSelected < num)
setSelected(mSelected + 1);
else if (mSelected == num && mWrappingEnabled)
setSelected(0);
event.consume();
}
else if (action == InputAction::GUI_HOME)
{
setSelected(0);
event.consume();
}
else if (action == InputAction::GUI_END && (getListModel() != nullptr))
{
setSelected(getListModel()->getNumberOfElements() - 1);
event.consume();
}
}
示例7: keyPressed
// -- KeyListener notifications
void GuiTable::keyPressed(KeyEvent& event)
{
const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
distributeActionEvent();
event.consume();
}
else if (action == InputAction::GUI_UP)
{
setSelectedRow(mSelectedRow - 1);
event.consume();
}
else if (action == InputAction::GUI_DOWN)
{
setSelectedRow(mSelectedRow + 1);
event.consume();
}
else if (action == InputAction::GUI_LEFT)
{
setSelectedColumn(mSelectedColumn - 1);
event.consume();
}
else if (action == InputAction::GUI_RIGHT)
{
setSelectedColumn(mSelectedColumn + 1);
event.consume();
}
else if (action == InputAction::GUI_HOME)
{
setSelectedRow(0);
setSelectedColumn(0);
event.consume();
}
else if (action == InputAction::GUI_END && mModel)
{
setSelectedRow(mModel->getRows() - 1);
setSelectedColumn(mModel->getColumns() - 1);
event.consume();
}
}
示例8: keyPressed
void LoginDialog::keyPressed(KeyEvent &event)
{
if (event.isConsumed())
{
mLoginButton->setEnabled(canSubmit());
return;
}
const int actionId = event.getActionId();
if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
{
action(ActionEvent(nullptr, mServerButton->getActionEventId()));
}
else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
|| actionId == static_cast<int>(InputAction::GUI_SELECT2))
{
action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
}
else
{
mLoginButton->setEnabled(canSubmit());
}
}
示例9: keyPressed
void TextBox::keyPressed(KeyEvent& event)
{
const Key &key = event.getKey();
const int action = event.getActionId();
switch (action)
{
case InputAction::GUI_LEFT:
{
--mCaretColumn;
if (mCaretColumn < 0)
{
--mCaretRow;
if (mCaretRow < 0)
{
mCaretRow = 0;
mCaretColumn = 0;
}
else
{
mCaretColumn = static_cast<int>(
mTextRows[mCaretRow].size());
}
}
break;
}
case InputAction::GUI_RIGHT:
{
++mCaretColumn;
if (mCaretColumn > static_cast<int>(mTextRows[mCaretRow].size()))
{
++ mCaretRow;
const int sz = static_cast<int>(mTextRows.size());
if (mCaretRow >= sz)
{
mCaretRow = sz - 1;
if (mCaretRow < 0)
mCaretRow = 0;
mCaretColumn = static_cast<int>(
mTextRows[mCaretRow].size());
}
else
{
mCaretColumn = 0;
}
}
break;
}
case InputAction::GUI_DOWN:
{
setCaretRow(mCaretRow + 1);
break;
}
case InputAction::GUI_UP:
{
setCaretRow(mCaretRow - 1);
break;
}
case InputAction::GUI_HOME:
{
mCaretColumn = 0;
break;
}
case InputAction::GUI_END:
{
mCaretColumn = static_cast<int>(mTextRows[mCaretRow].size());
break;
}
case InputAction::GUI_SELECT2:
{
if (mEditable)
{
mTextRows.insert(mTextRows.begin() + mCaretRow + 1,
mTextRows[mCaretRow].substr(mCaretColumn,
mTextRows[mCaretRow].size() - mCaretColumn));
mTextRows[mCaretRow].resize(mCaretColumn);
++mCaretRow;
mCaretColumn = 0;
}
break;
}
case InputAction::GUI_BACKSPACE:
{
if (mCaretColumn != 0 && mEditable)
{
mTextRows[mCaretRow].erase(mCaretColumn - 1, 1);
--mCaretColumn;
}
else if (mCaretColumn == 0 && mCaretRow != 0 && mEditable)
{
mCaretColumn = static_cast<int>(
mTextRows[mCaretRow - 1].size());
mTextRows[mCaretRow - 1] += mTextRows[mCaretRow];
//.........这里部分代码省略.........