diff --git a/lcl/interfaces/carbon/carbonprivate.pp b/lcl/interfaces/carbon/carbonprivate.pp index 3a426fd951..5e9f756f5a 100644 --- a/lcl/interfaces/carbon/carbonprivate.pp +++ b/lcl/interfaces/carbon/carbonprivate.pp @@ -404,8 +404,10 @@ var SavedMouseUpMsg: TLMMouse; var PostponedDownMsg: TLMMouse; var PostponedDown: Boolean; +// Stores last mouse info for multiple clicks +var LastMouse: TLastMouseInfo; // Stores last mouse pos to call mouse move only when it really has changed -var LastMousePos: TPoint; +var LastMousePos: TPoint; // in client coordinates {$I carbonprivatecommon.inc} {$I carbonprivatecontrol.inc} diff --git a/lcl/interfaces/carbon/carbonprivatecommon.inc b/lcl/interfaces/carbon/carbonprivatecommon.inc index 1aaaa3984b..a9e9af091f 100644 --- a/lcl/interfaces/carbon/carbonprivatecommon.inc +++ b/lcl/interfaces/carbon/carbonprivatecommon.inc @@ -206,8 +206,6 @@ end; function CarbonCommon_Track(ANextHandler: EventHandlerCallRef; AEvent: EventRef; AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF} -const - MSGKIND: array[1..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP); var ActionUPP, OldActionUPP: ControlActionUPP; P: TPoint; @@ -266,14 +264,13 @@ begin FillChar(Msg{%H-}, SizeOf(Msg), 0); - if (MouseButton >= Low(MSGKIND)) and (MouseButton <= High(MSGKIND)) then - Msg.Msg := MSGKIND[MouseButton]; - P := AWidget.GetMousePos; Msg.XPos := P.X; Msg.YPos := P.Y; Msg.Keys := GetCarbonMsgKeyState; - case GetCarbonMouseClickCount(AEvent) of + Msg.Msg := CheckMouseButtonDownUp(AWidget.LCLObject, LastMouse, + AWidget.LCLObject.ClientToScreen(P), MouseButton, False); + case LastMouse.ClickCount of 2: Msg.Keys := msg.Keys or MK_DOUBLECLICK; 3: Msg.Keys := msg.Keys or MK_TRIPLECLICK; 4: Msg.Keys := msg.Keys or MK_QUADCLICK; diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index ea148c4d1c..a6523fad8c 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -133,17 +133,8 @@ const // handler functions // procedure HandleMouseDownEvent(var AMsg); - const - // array of clickcount x buttontype - MSGKIND: array[1..4, 1..3] of Integer = ( - (LM_LBUTTONDOWN, LM_RBUTTONDOWN, LM_MBUTTONDOWN), - (LM_LBUTTONDBLCLK, LM_RBUTTONDBLCLK, LM_MBUTTONDBLCLK), - (LM_LBUTTONTRIPLECLK, LM_RBUTTONTRIPLECLK, LM_MBUTTONTRIPLECLK), - (LM_LBUTTONQUADCLK, LM_RBUTTONQUADCLK, LM_MBUTTONQUADCLK) - ); var MouseButton: Integer; - ClickCount: Integer; MousePoint: TPoint; Msg: ^TLMMouse; begin @@ -152,30 +143,28 @@ const {$ENDIF} Msg := @AMsg; - ClickCount := GetCarbonMouseClickCount(AEvent); MouseButton := GetCarbonMouseButton(AEvent); MousePoint := GetMousePoint; - if (ClickCount < Low(MSGKIND)) or (ClickCount > High(MSGKIND)) then - ClickCount := (ClickCount mod High(MSGKIND))+1; - - if (MouseButton < Low(MSGKIND[1])) or (MouseButton > High(MSGKIND[1])) then Exit; - Msg^.Msg := MSGKIND[ClickCount, MouseButton]; + Msg^.Msg := CheckMouseButtonDownUp(Widget.LCLObject, LastMouse, + Widget.LCLObject.ClientToScreen(MousePoint), MouseButton, True); //debugln('HandleMouseDownEvent CliCount=',dbgs(ClickCount),' MouseButton=',dbgs(MouseButton),' Pos=',dbgs(MousePoint)); Msg^.XPos := MousePoint.X; Msg^.YPos := MousePoint.Y; Msg^.Keys := GetCarbonMsgKeyState; - + case LastMouse.ClickCount of + 2: Msg^.Keys := Msg^.Keys or MK_DOUBLECLICK; + 3: Msg^.Keys := Msg^.Keys or MK_TRIPLECLICK; + 4: Msg^.Keys := Msg^.Keys or MK_QUADCLICK; + end; CarbonWidgetSet.SetCaptureWidget(HWND(Widget)); - if ClickCount > 1 then Postpone := True; + if LastMouse.ClickCount > 1 then Postpone := True; end; procedure HandleMouseUpEvent(var AMsg); - const - MSGKIND: array[1..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP); var MouseButton: Integer; MousePoint: TPoint; @@ -191,13 +180,18 @@ const MouseButton := GetCarbonMouseButton(AEvent); MousePoint := GetMousePoint; - if (MouseButton >= Low(MSGKIND)) and (MouseButton <= High(MSGKIND)) then - Msg^.Msg := MSGKIND[MouseButton]; + Msg^.Msg := CheckMouseButtonDownUp(Widget.LCLObject, LastMouse, + Widget.LCLObject.ClientToScreen(MousePoint), MouseButton, False); Msg^.XPos := MousePoint.X; Msg^.YPos := MousePoint.Y; Msg^.Keys := GetCarbonMsgKeyState; - + case LastMouse.ClickCount of + 2: Msg^.Keys := Msg^.Keys or MK_DOUBLECLICK; + 3: Msg^.Keys := Msg^.Keys or MK_TRIPLECLICK; + 4: Msg^.Keys := Msg^.Keys or MK_QUADCLICK; + end; + CarbonWidgetSet.SetCaptureWidget(0); end;