mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:39:18 +02:00
LCL-CustomDrawn-Cocoa: Improves ClientToScreen, now it returns LCL screen coordinates and is much closer to the real positions for non-windowed controls
git-svn-id: trunk@37207 -
This commit is contained in:
parent
44f5d11c10
commit
f7a49a4d03
@ -1166,10 +1166,9 @@ begin
|
||||
// Position is in screen coordinates!
|
||||
else if attribute.isEqualToString(NSAccessibilityPositionAttribute) then
|
||||
begin
|
||||
//lPoint := LCLAcc.Position;
|
||||
lPoint := LCLControl.ClientToScreen(Types.Point(0, 0));
|
||||
lNSPoint.x := lPoint.X;
|
||||
lNSPoint.y := lPoint.Y;
|
||||
lNSPoint.y := Screen.Height - lPoint.Y;
|
||||
Result := NSValue.valueWithPoint(lNSPoint);
|
||||
{$ifdef VerboseCDAccessibility}
|
||||
DebugLn(Format(':<[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityPositionAttribute Result=%d,%d', [lPoint.X, lPoint.Y]));
|
||||
|
@ -27,6 +27,7 @@ var
|
||||
lPoint: NSPoint;
|
||||
lCocoaForm: TCocoaForm; // NSWindow
|
||||
lClientFrame: NSRect;
|
||||
lOriginalControlHeight: Integer = 0;
|
||||
begin
|
||||
Result := False;
|
||||
if Handle = 0 then Exit;
|
||||
@ -34,6 +35,10 @@ begin
|
||||
// Go throught the non-native controls
|
||||
ControlHandle := TCDBaseControl(Handle);
|
||||
lOriginalControl := ControlHandle.GetWinControl();
|
||||
// If we are doing an operation in the form itself, don't correct with the control height
|
||||
if not (ControlHandle is TCocoaWindow) then
|
||||
lOriginalControlHeight := lOriginalControl.Height;
|
||||
|
||||
while not (ControlHandle is TCocoaWindow) do
|
||||
begin
|
||||
lControl := ControlHandle.GetWinControl();
|
||||
@ -49,12 +54,12 @@ begin
|
||||
// Now actually do the convertion
|
||||
lClientFrame := TCocoaWindow(ControlHandle).ClientArea.frame;
|
||||
lPoint.x := lClientFrame.origin.X + P.X;
|
||||
lPoint.Y := lClientFrame.origin.Y + lClientFrame.size.height - P.Y - lOriginalControl.Height;
|
||||
lPoint.Y := lClientFrame.origin.Y + lClientFrame.size.height - P.Y - lOriginalControlHeight;
|
||||
lCocoaForm := TCocoaWindow(ControlHandle).CocoaForm;
|
||||
if lCocoaForm = nil then Exit;
|
||||
lPoint := lCocoaForm.convertBaseToScreen(lPoint);
|
||||
P.x := Round(lPoint.X);
|
||||
P.Y := Round(lPoint.Y);
|
||||
P.Y := Screen.Height - Round(lPoint.Y);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user