void ComboBox::keyPressEvent(QKeyEvent* e) { if ( !hasFocus() ) { return; } else { if (e->key() == Qt::Key_Up) { setCurrentIndex( (activeIndex() - 1 < 0) ? count() - 1 : activeIndex() - 1 ); } else if (e->key() == Qt::Key_Down) { setCurrentIndex( (activeIndex() + 1) % count() ); } else { QFrame::keyPressEvent(e); } } _currentDelta = 0; }
void QvisColorGridWidget::keyPressEvent(QKeyEvent *e) { QColor temp; int column = activeIndex() % numColumns; int row = activeIndex() / numColumns; // Handle the key strokes. switch(e->key()) { case Qt::Key_Escape: // emit an empty color. emit selectedColor(temp); break; case Qt::Key_Return: case Qt::Key_Enter: setSelectedIndex(activeIndex()); break; case Qt::Key_Left: if(column == 0) setActiveIndex(getIndex(row, numColumns - 1)); else setActiveIndex(getIndex(row, column - 1)); break; case Qt::Key_Right: if(column == numColumns - 1) setActiveIndex(getIndex(row, 0)); else setActiveIndex(getIndex(row, column + 1)); break; case Qt::Key_Up: if(row == 0) setActiveIndex(getIndex(numRows - 1, column)); else setActiveIndex(getIndex(row - 1, column)); break; case Qt::Key_Down: if(row == numRows - 1) setActiveIndex(getIndex(0, column)); else setActiveIndex(getIndex(row + 1, column)); break; } }
NATRON_NAMESPACE_ENTER void TabWidgetI::toSerialization(SERIALIZATION_NAMESPACE::SerializationObjectBase* serializationBase) { SERIALIZATION_NAMESPACE::TabWidgetSerialization* serialization = dynamic_cast<SERIALIZATION_NAMESPACE::TabWidgetSerialization*>(serializationBase); if (!serialization) { return; } serialization->tabs = getTabScriptNames(); serialization->scriptName = getScriptName(); serialization->isAnchor = isAnchor(); serialization->currentIndex = activeIndex(); }
void ComboBox::wheelEvent(QWheelEvent *e) { if (ignoreWheelEvent) { return QFrame::wheelEvent(e); } if ( !hasFocus() ) { return; } // a standard wheel click is 120 _currentDelta += e->delta(); if ( (_currentDelta <= -120) || (120 <= _currentDelta) ) { int c = count(); int i = activeIndex(); int delta = _currentDelta / 120; _currentDelta -= delta * 120; i = (i - delta) % c; if (i < 0) { i += c; } setCurrentIndex(i); } }