All pastes #958746 Raw Edit

Miscellany

public text v1 · immutable
#958746 ·published 2008-03-26 22:15 UTC
rendered paste body
bool MythUITextEdit::keyPressEvent(QKeyEvent *e)
{
    QStringList actions;
    bool handled = false;

    GetMythMainWindow()->TranslateKeyPress("Global", e, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {

        QString action = actions[i];
        handled = true;

        if (action == "SELECT")
        {
            emit Finished();
        }
        else if (action == "LEFT")
        {
            MoveCursor(MoveLeft);
        }
        else if (action == "RIGHT")
        {
            MoveCursor(MoveRight);
        }
        else if (action == "BACKSPACE" || action == "DELETE")
        {
            RemoveCharacter();
        }
        else
            handled = false;
    }

    const QChar *character = e->text().unicode();
    if (!handled && (character->isLetterOrNumber() || character->isPunct()
        || character->isSpace() || character->isSymbol()))
    {
         InsertCharacter(e->text());
        handled = true;
    }

    return handled;
}