当前位置: 首页>>代码示例>>C++>>正文


C++ KeyEvent::getActionId方法代码示例

本文整理汇总了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);
    }
}
开发者ID:KaneHart,项目名称:Elmlor-Client,代码行数:55,代码来源:quitdialog.cpp

示例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);
}
开发者ID:nashley,项目名称:ManaPlus,代码行数:49,代码来源:serverdialog.cpp

示例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;
    }
}
开发者ID:supermukmin,项目名称:ManaPlus,代码行数:15,代码来源:charcreatedialog.cpp

示例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()));
    }
}
开发者ID:nashley,项目名称:ManaPlus,代码行数:15,代码来源:worldselectdialog.cpp

示例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()));
    }
}
开发者ID:dreamsxin,项目名称:ManaPlus,代码行数:17,代码来源:editserverdialog.cpp

示例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();
    }
}
开发者ID:mekolat,项目名称:ManaPlus,代码行数:42,代码来源:listbox.cpp

示例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();
    }
}
开发者ID:Action-Committee,项目名称:ManaPlus,代码行数:43,代码来源:guitable.cpp

示例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());
    }
}
开发者ID:qpulsar,项目名称:ManaPlus,代码行数:23,代码来源:logindialog.cpp

示例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];
//.........这里部分代码省略.........
开发者ID:KaneHart,项目名称:Elmlor-Client,代码行数:101,代码来源:textbox.cpp


注:本文中的KeyEvent::getActionId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。