bool QWindowsMouseHandler::translateScrollEvent(QWindow *window, HWND, MSG msg, LRESULT *) { // This is a workaround against some touchpads that send WM_HSCROLL instead of WM_MOUSEHWHEEL. // We could also handle vertical scroll here but there's no reason to, there's no bug for vertical // (broken vertical scroll would have been noticed long time ago), so lets keep the change small // and minimize the chance for regressions. int delta = 0; switch (LOWORD(msg.wParam)) { case SB_LINELEFT: delta = 120; break; case SB_LINERIGHT: delta = -120; break; case SB_PAGELEFT: delta = 240; break; case SB_PAGERIGHT: delta = -240; break; default: return false; } redirectWheelEvent(window, QCursor::pos(), delta, Qt::Horizontal, Qt::NoModifier); return true; }
bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, MSG msg, LRESULT *) { const Qt::KeyboardModifiers mods = keyStateToModifiers(int(msg.wParam)); int delta; if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) delta = GET_WHEEL_DELTA_WPARAM(msg.wParam); else delta = int(msg.wParam); Qt::Orientation orientation = (msg.message == WM_MOUSEHWHEEL || (mods & Qt::AltModifier)) ? Qt::Horizontal : Qt::Vertical; // according to the MSDN documentation on WM_MOUSEHWHEEL: // a positive value indicates that the wheel was rotated to the right; // a negative value indicates that the wheel was rotated to the left. // Qt defines this value as the exact opposite, so we have to flip the value! if (msg.message == WM_MOUSEHWHEEL) delta = -delta; const QPoint globalPos(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); redirectWheelEvent(window, globalPos, delta, orientation, mods); return true; }
void Piano::wheelEvent(QWheelEvent* ev) { emit redirectWheelEvent(ev); }
void WidgetStack::wheelEvent(QWheelEvent* ev) { emit redirectWheelEvent(ev); }