mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 14:40:29 +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!
|
// Position is in screen coordinates!
|
||||||
else if attribute.isEqualToString(NSAccessibilityPositionAttribute) then
|
else if attribute.isEqualToString(NSAccessibilityPositionAttribute) then
|
||||||
begin
|
begin
|
||||||
//lPoint := LCLAcc.Position;
|
|
||||||
lPoint := LCLControl.ClientToScreen(Types.Point(0, 0));
|
lPoint := LCLControl.ClientToScreen(Types.Point(0, 0));
|
||||||
lNSPoint.x := lPoint.X;
|
lNSPoint.x := lPoint.X;
|
||||||
lNSPoint.y := lPoint.Y;
|
lNSPoint.y := Screen.Height - lPoint.Y;
|
||||||
Result := NSValue.valueWithPoint(lNSPoint);
|
Result := NSValue.valueWithPoint(lNSPoint);
|
||||||
{$ifdef VerboseCDAccessibility}
|
{$ifdef VerboseCDAccessibility}
|
||||||
DebugLn(Format(':<[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityPositionAttribute Result=%d,%d', [lPoint.X, lPoint.Y]));
|
DebugLn(Format(':<[TCocoaAccessibleObject.accessibilityAttributeValue] NSAccessibilityPositionAttribute Result=%d,%d', [lPoint.X, lPoint.Y]));
|
||||||
|
@ -27,6 +27,7 @@ var
|
|||||||
lPoint: NSPoint;
|
lPoint: NSPoint;
|
||||||
lCocoaForm: TCocoaForm; // NSWindow
|
lCocoaForm: TCocoaForm; // NSWindow
|
||||||
lClientFrame: NSRect;
|
lClientFrame: NSRect;
|
||||||
|
lOriginalControlHeight: Integer = 0;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if Handle = 0 then Exit;
|
if Handle = 0 then Exit;
|
||||||
@ -34,6 +35,10 @@ begin
|
|||||||
// Go throught the non-native controls
|
// Go throught the non-native controls
|
||||||
ControlHandle := TCDBaseControl(Handle);
|
ControlHandle := TCDBaseControl(Handle);
|
||||||
lOriginalControl := ControlHandle.GetWinControl();
|
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
|
while not (ControlHandle is TCocoaWindow) do
|
||||||
begin
|
begin
|
||||||
lControl := ControlHandle.GetWinControl();
|
lControl := ControlHandle.GetWinControl();
|
||||||
@ -49,12 +54,12 @@ begin
|
|||||||
// Now actually do the convertion
|
// Now actually do the convertion
|
||||||
lClientFrame := TCocoaWindow(ControlHandle).ClientArea.frame;
|
lClientFrame := TCocoaWindow(ControlHandle).ClientArea.frame;
|
||||||
lPoint.x := lClientFrame.origin.X + P.X;
|
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;
|
lCocoaForm := TCocoaWindow(ControlHandle).CocoaForm;
|
||||||
if lCocoaForm = nil then Exit;
|
if lCocoaForm = nil then Exit;
|
||||||
lPoint := lCocoaForm.convertBaseToScreen(lPoint);
|
lPoint := lCocoaForm.convertBaseToScreen(lPoint);
|
||||||
P.x := Round(lPoint.X);
|
P.x := Round(lPoint.X);
|
||||||
P.Y := Round(lPoint.Y);
|
P.Y := Screen.Height - Round(lPoint.Y);
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user