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:
sekelsenmat 2012-05-07 07:07:21 +00:00
parent 44f5d11c10
commit f7a49a4d03
2 changed files with 8 additions and 4 deletions

View File

@ -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]));

View File

@ -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;