コード例 #1
0
void KTabBar::wheelEvent( QWheelEvent *event )
{
  if ( !( event->orientation() == Qt::Horizontal ) ) {
    if ( receivers( SIGNAL(wheelDelta(int)) ) ) {
      emit( wheelDelta( event->delta() ) );
      return;
    }
    int lastIndex = count() - 1;
    //Set an invalid index as base case
    int targetIndex = -1;
    bool forward = event->delta() < 0;
    if ( forward && lastIndex == currentIndex() ) {
      targetIndex = 0;
    }
    else if ( !forward && 0 == currentIndex() ) {
      targetIndex = lastIndex;
    }
    //Will not move when targetIndex is invalid
    setCurrentIndex( targetIndex );
    //If it has not moved yet (targetIndex == -1), or if it moved but current tab is disabled
    if ( targetIndex != currentIndex() || !isTabEnabled( targetIndex ) ) {
      QTabBar::wheelEvent( event );
    }
    event->accept();
  } else {
コード例 #2
0
LRESULT WebPopupMenuProxyWin::onMouseWheel(HWND hWnd, UINT message, WPARAM wParam, LPARAM, bool& handled)
{
    handled = true;

    if (!scrollbar())
        return 0;

    int i = 0;
    for (incrementWheelDelta(GET_WHEEL_DELTA_WPARAM(wParam)); abs(wheelDelta()) >= WHEEL_DELTA; reduceWheelDelta(WHEEL_DELTA)) {
        if (wheelDelta() > 0)
            ++i;
        else
            --i;
    }

    ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i));
    return 0;
}