From 728361e306986dd3f4ed66f57fd8fac79168218c Mon Sep 17 00:00:00 2001 From: dmitry Date: Tue, 14 Aug 2018 15:37:28 +0000 Subject: [PATCH] cocoa: update interface ClientToScreen api call to recognize clientOffset for non-composite controls. todo: ScreenToClient must be updated accordingly git-svn-id: trunk@58704 - --- lcl/interfaces/cocoa/cocoawinapi.inc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index 24a501ab02..953d8ab745 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -94,12 +94,27 @@ begin end; function TCocoaWidgetSet.ClientToScreen(Handle: HWND; var P: TPoint): Boolean; +var + r : NSRect; + cl : NSView; + clr : TRect; begin Result := Handle <> 0; if Result then + begin // must use lclContentView! - it's client view - NSObject(Handle).lclContentView.lclLocalToScreen(P.X, P.Y); + cl := NSObject(Handle).lclContentView; + if HWND(cl) = Handle then + begin + // if Handle is lclContentView, then we should check clientRect + // (i.e. TabControl doesn't have lclContentView, yet its clientRect is adjusted) + clr := NSObject(Handle).lclClientFrame; + P.X := P.X + clr.Left; + P.Y := P.Y + clr.Top; + end; + cl.lclLocalToScreen(P.X, P.Y); + end; end; procedure TCocoaWidgetSet.CallDefaultWndHandler(Sender: TObject; var Message);