From 46694496eec639ebab4d550a451b7dfdf327708b Mon Sep 17 00:00:00 2001 From: rich2014 Date: Fri, 22 Sep 2023 19:06:22 +0800 Subject: [PATCH] Cocoa: fix #40517: eliminate cursor flickering when dragging CustomControl --- lcl/interfaces/cocoa/cocoaprivate.pas | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lcl/interfaces/cocoa/cocoaprivate.pas b/lcl/interfaces/cocoa/cocoaprivate.pas index aebddd849e..ecc47816b6 100644 --- a/lcl/interfaces/cocoa/cocoaprivate.pas +++ b/lcl/interfaces/cocoa/cocoaprivate.pas @@ -463,6 +463,8 @@ function NSViewCanFocus(v: NSView): Boolean; implementation +uses CocoaWSCommon; + function NSObjectIsLCLEnabled(obj: NSObject): Boolean; begin if obj.isKindOfClass(NSView) then @@ -862,6 +864,8 @@ end; procedure TCocoaCustomControl.mouseDragged(event: NSEvent); begin + window.disableCursorRects; + if not Assigned(callback) or not callback.MouseMove(event) then // calling inherited causes the drag event to be passed to the // parent controls @@ -905,6 +909,13 @@ end; procedure TCocoaCustomControl.mouseUp(event: NSEvent); begin + if not window.areCursorRectsEnabled then + begin + window.enableCursorRects; + window.resetCursorRects; + CursorHelper.SetCursorAtMousePos; + end; + if not Assigned(callback) or not callback.MouseUpDownEvent(event) then inherited mouseUp(event); end;