From f0f5beb5cf1110e407a2a5644882cd4d62554845 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sat, 5 May 2012 09:58:28 +0000 Subject: [PATCH] Fixes a bug in the code to iterate accessible objects, it didnt work, now it does git-svn-id: trunk@37159 - --- lcl/include/control.inc | 5 +++-- lcl/interfaces/customdrawn/customdrawn_cocoaproc.pas | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 45ffeaba4e..b775f97674 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -275,7 +275,8 @@ begin begin FLastSearchIndex := 1; FLastSearchInSubcontrols := True; - Result := TWinControl(OwnerControl).Controls[0].GetAccessibleObject(); + if (TWinControl(OwnerControl).ControlCount > 0) then + Result := TWinControl(OwnerControl).Controls[0].GetAccessibleObject(); end; end; @@ -295,7 +296,7 @@ begin end else begin - if TWinControl(OwnerControl).ControlCount < FLastSearchIndex then + if TWinControl(OwnerControl).ControlCount > FLastSearchIndex then begin Result := TWinControl(OwnerControl).Controls[FLastSearchIndex].GetAccessibleObject(); Inc(FLastSearchIndex); diff --git a/lcl/interfaces/customdrawn/customdrawn_cocoaproc.pas b/lcl/interfaces/customdrawn/customdrawn_cocoaproc.pas index 58a7e55a87..10cde8adec 100644 --- a/lcl/interfaces/customdrawn/customdrawn_cocoaproc.pas +++ b/lcl/interfaces/customdrawn/customdrawn_cocoaproc.pas @@ -710,8 +710,10 @@ var begin Result := inherited accessibilityAttributeValue(attribute); + {$ifdef VerboseCDAccessibility} //lStrAttr := NSStringToString(attribute); //DebugLn('[TCocoaCustomControl.accessibilityAttributeValue] attribute='+lStrAttr); + {$endif} if attribute.isEqualToString(NSAccessibilityChildrenAttribute) then begin @@ -958,7 +960,7 @@ begin lStrAttr := '[TCocoaCustomControl.accessibilityAttributeValue] NSAccessibilityChildrenAttribute'; {$endif} lAResult := NSArray(Result); - lMAResult := lAResult.mutableCopy(); + lMAResult := NSMutableArray.arrayWithCapacity(0); //lAResult.mutableCopy(); lForm := WindowHandle.LCLForm; lFormAcc := lForm.GetAccessibleObject(); lChildAcc := lFormAcc.GetFirstChildAccessibleObject(); @@ -1090,7 +1092,12 @@ begin {$endif} // if the parent is a form, pass to the custom control if lParent is TCustomForm then - Result := TCocoaWindow(lParent.Handle).ClientArea + begin + Result := TCocoaWindow(lParent.Handle).ClientArea; + {$ifdef VerboseCDAccessibility} + DebugLn(':[TCocoaAccessibleObject.accessibilityAttributeValue] Parent is TCustomForm, so redirecting to ClientArea'); + {$endif} + end else Result := TCocoaAccessibleObject(lParent.GetAccessibleObject().Handle); end