Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QAbstractButton::keyPressEvent ( QKeyEvent e  )  [protected, virtual, inherited]

Reimplemented from QWidget.

Reimplemented in QPushButton.

Definition at line 1144 of file qabstractbutton.cpp.

References QCoreApplication::flush(), QEvent::ignore(), QKeyEvent::isAutoRepeat(), QKeyEvent::key(), and QWidget::repaint().

Referenced by QPushButton::keyPressEvent().

{
    Q_D(QAbstractButton);
    bool next = true;
    switch (e->key()) {
    case Qt::Key_Enter:
    case Qt::Key_Return:
        e->ignore();
        break;
    case Qt::Key_Select:
    case Qt::Key_Space:
        if (!e->isAutoRepeat()) {
            setDown(true);
            repaint(); //flush paint event before invoking potentially expensive operation
            QApplication::flush();
            d->emitPressed();
        }
        break;
    case Qt::Key_Up:
    case Qt::Key_Left:
        next = false;
        // fall through
    case Qt::Key_Right:
    case Qt::Key_Down:
#ifdef QT_KEYPAD_NAVIGATION
        if (QApplication::keypadNavigationEnabled() && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right)) {
            e->ignore();
            return;
        }
#endif
        d->moveFocus(e->key());
        if (hasFocus()) // nothing happend, propagate
            e->ignore();
        break;
    case Qt::Key_Escape:
        if (d->down) {
            setDown(false);
            repaint(); //flush paint event before invoking potentially expensive operation
            QApplication::flush();
            d->emitReleased();
            break;
        }
        // fall through
    default:
        e->ignore();
    }
}


Generated by  Doxygen 1.6.0   Back to index