void QgsColorSwatchGrid::keyPressEvent( QKeyEvent *event ) { //handle keyboard navigation if ( event->key() == Qt::Key_Right ) { mCurrentFocusBox = std::min( mCurrentFocusBox + 1, mColors.length() - 1 ); } else if ( event->key() == Qt::Key_Left ) { mCurrentFocusBox = std::max( mCurrentFocusBox - 1, 0 ); } else if ( event->key() == Qt::Key_Up ) { int currentRow = mCurrentFocusBox / NUMBER_COLORS_PER_ROW; int currentColumn = mCurrentFocusBox % NUMBER_COLORS_PER_ROW; currentRow--; if ( currentRow >= 0 ) { mCurrentFocusBox = currentRow * NUMBER_COLORS_PER_ROW + currentColumn; } else { //moved above first row focusPreviousChild(); } } else if ( event->key() == Qt::Key_Down ) { int currentRow = mCurrentFocusBox / NUMBER_COLORS_PER_ROW; int currentColumn = mCurrentFocusBox % NUMBER_COLORS_PER_ROW; currentRow++; int box = currentRow * NUMBER_COLORS_PER_ROW + currentColumn; if ( box < mColors.length() ) { mCurrentFocusBox = box; } else { //moved below first row focusNextChild(); } } else if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space ) { //color clicked emit colorChanged( mColors.at( mCurrentFocusBox ).first ); } else { //some other key, pass it on QWidget::keyPressEvent( event ); return; } repaint(); }
void ListBox::keyPressEvent(QKeyEvent* event) { int key = event->key(); if (key == Qt::Key_Escape) { focusPreviousChild(); deleteLater(); event->accept(); } else { QListWidget::keyPressEvent(event); } }
void XQListWidget::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Left: { focusPreviousChild(); break; } case Qt::Key_Right: { focusNextChild(); break; } default: { QListWidget::keyPressEvent(event); } } }
bool DhQGLWidget::DvhfocusPreviousChild() { return focusPreviousChild(); }
bool DhQPushButton::DvhfocusPreviousChild() { return focusPreviousChild(); }
bool DhQAbstractSpinBox::DvhfocusPreviousChild() { return focusPreviousChild(); }
bool DhQGroupBox::DvhfocusPreviousChild() { return focusPreviousChild(); }
void KComboEdit::keyPressEvent(QKeyEvent *e) { int count = 0; int row = 0; if((NULL==e) || (NULL==dropDown) || (NULL==buttonLeft) || (NULL==buttonRight)) { return; } buttonLeft->setChecked(false); buttonRight->setChecked(false); count = dropDown->count(); row = dropDown->currentRow(); switch(e->key()) { case Qt::Key_Up: if(!dropDown->isHidden()) { row -= 1; if (row < 0) { row = count - 1; } setRow(row); } else { focusPreviousChild(); } break; case Qt::Key_Down: if(!dropDown->isHidden()) { row += 1;; if (row >= count) { row = 0; } setRow(row); } else { focusNextChild(); } break; case Qt::Key_Left: if(dropDown->isHidden()) { row -= 1; if (row < 0) { row = count - 1; } setRow(row); buttonLeft->setChecked(true); buttonRight->setChecked(false); } break; case Qt::Key_Right: if(dropDown->isHidden()) { row += 1; if (row >= count) { row = 0; } setRow(row); buttonLeft->setChecked(false); buttonRight->setChecked(true); } break; case Qt::Key_Return: case Qt::Key_Enter: if(dropDown->isHidden()) { dropDown->show(); } else { dropDown->hide(); } break; default: QLineEdit::keyPressEvent(e); break; } }
bool DhQSlider::DvhfocusPreviousChild() { return focusPreviousChild(); }
bool DhQScrollArea::DvhfocusPreviousChild() { return focusPreviousChild(); }
bool DhQStackedWidget::DvhfocusPreviousChild() { return focusPreviousChild(); }