diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index 223f6a9726..1d650fd588 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -116,6 +116,8 @@ const function GetMouseWheelDelta: Integer; var WheelDelta: SInt32; + CCtl: TCarbonCustomControl; + ScrollInfo: TScrollInfo; begin Result := 0; @@ -127,7 +129,22 @@ const // Carbon's WheelDelta is the number of lines to be scrolled // LCL expects the delta to be 120 for each wheel step, which should scroll // Mouse.WheelScrollLines lines (defaults to three) + // Update: 20111212 by zeljko: All widgetsets sends WheelDelta +-120 + // mac sends 1 or -1 so we just recalc that to wheel delta. see issue #20888 Result := (120 * WheelDelta) div Mouse.WheelScrollLines; + if Widget.ClassType = TCarbonCustomControl then + begin + CCtl := TCarbonCustomControl(Widget); + if CCtl.GetScrollbarVisible(SB_VERT) then + begin + FillChar(ScrollInfo, SizeOf(ScrollInfo), #0); + ScrollInfo.fMask := SIF_TRACKPOS; + ScrollInfo.cbSize := SizeOf(ScrollInfo); + CCtl.GetScrollInfo(SB_VERT, ScrollInfo); + if (WheelDelta > 0) and (ScrollInfo.nTrackPos = 0) then + Result := 120; + end; + end; {$IFDEF VerboseMouse} DebugLn('GetMouseWheelDelta WheelDelta=', DbgS(WheelDelta), ' ', HexStr(WheelDelta, 8)); {$ENDIF} diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 8b27901216..fb9aef0c75 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -3277,6 +3277,9 @@ var MousePos: TQtPoint; Modifiers: QtKeyboardModifiers; ModifierState: PtrInt; + {$IFDEF DARWIN} + CCtl: TQtAbstractScrollArea; + {$ENDIF} begin Result := False; if not CanSendLCLMessage or (LCLObject = nil) then @@ -3307,6 +3310,31 @@ begin Msg.WheelDelta := QWheelEvent_delta(QWheelEventH(Event)); + {$IFDEF DARWIN} + // LCL expects delta +-120, we must fix it. issue #20888 + if (ChildOfComplexWidget in [ccwCustomControl, ccwAbstractScrollArea, + ccwScrollingWinControl]) then + begin + if (Msg.WheelDelta > 0) then + Msg.WheelDelta := 1 + else + Msg.WheelDelta := -1; + Msg.WheelDelta := (120 * Msg.WheelDelta) div Mouse.WheelScrollLines; + if FOwner <> nil then + CCtl := TQtAbstractScrollArea(FOwner) + else + CCtl := TQtAbstractScrollArea(Self); + //now fix ugly behaviour. + if (Msg.WheelDelta > 0) and (CCtl.FVScrollbar.getVisible) and + ((CCtl.FVScrollBar = Self) or + (Assigned(CCtl.FVScrollbar) and (Self <> CCtl.FHScrollbar))) then + begin + if CCtl.FVScrollbar.getSliderPosition <= 1 then + Msg.WheelDelta := 120; + end; + end; + {$ENDIF} + NotifyApplicationUserInput(Msg.Msg); Result := DeliverMessage(Msg) <> 0;