Carbon,QtMac: fixed wrong behaviour of mouse wheel scroll,because LCL assumes 120 as wheel delta.issue #20888

git-svn-id: trunk@34137 -
This commit is contained in:
zeljko 2011-12-12 16:54:28 +00:00
parent e52894ea3f
commit 2b4adf30f7
2 changed files with 45 additions and 0 deletions

View File

@ -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}

View File

@ -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;