mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 12:39:53 +02:00
Implements AccessibleValue for TTreeView items even when reading from the lfm. Improves the Carbon accessibility code for lists
git-svn-id: trunk@34830 -
This commit is contained in:
parent
bd8a968767
commit
ec6c831a3b
@ -959,7 +959,7 @@ type
|
|||||||
property AccessibleDescription: TCaption read FAccessibleDescription write SetAccessibleDescription;
|
property AccessibleDescription: TCaption read FAccessibleDescription write SetAccessibleDescription;
|
||||||
property AccessibleValue: TCaption read FAccessibleValue write SetAccessibleValue;
|
property AccessibleValue: TCaption read FAccessibleValue write SetAccessibleValue;
|
||||||
property AccessibleRole: TLazAccessibilityRole read FAccessibleRole write SetAccessibleRole;
|
property AccessibleRole: TLazAccessibilityRole read FAccessibleRole write SetAccessibleRole;
|
||||||
property Handle: PtrInt read GetHandle;
|
property Handle: PtrInt read GetHandle write FHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{* Note on TControl.Caption
|
{* Note on TControl.Caption
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
|
|
||||||
{ $DEFINE TREEVIEW_DEBUG}
|
{ $DEFINE TREEVIEW_DEBUG}
|
||||||
|
|
||||||
{ TTreeViewAccessibleObject }
|
|
||||||
|
|
||||||
const
|
const
|
||||||
TTreeNodeWithPointerStreamVersion : word = 1;
|
TTreeNodeWithPointerStreamVersion : word = 1;
|
||||||
TTreeNodeStreamVersion : word = 2;
|
TTreeNodeStreamVersion : word = 2;
|
||||||
@ -398,6 +396,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTreeNode.SetText(const S: string);
|
procedure TTreeNode.SetText(const S: string);
|
||||||
|
var
|
||||||
|
lSelfAX: TLazAccessibleObject;
|
||||||
begin
|
begin
|
||||||
if S=FText then exit;
|
if S=FText then exit;
|
||||||
FText := S;
|
FText := S;
|
||||||
@ -409,6 +409,10 @@ begin
|
|||||||
else TreeView.AlphaSort;
|
else TreeView.AlphaSort;
|
||||||
end;
|
end;
|
||||||
Update;
|
Update;
|
||||||
|
// Update accessibility information
|
||||||
|
lSelfAX := TreeView.GetAccessibleObject.GetChildAccessibleObjectWithDataObject(Self);
|
||||||
|
if lSelfAX <> nil then
|
||||||
|
lSelfAX.AccessibleValue := S;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTreeNode.SetData(AValue: Pointer);
|
procedure TTreeNode.SetData(AValue: Pointer);
|
||||||
@ -1740,6 +1744,7 @@ var
|
|||||||
OldInfo: TOldTreeNodeInfo;
|
OldInfo: TOldTreeNodeInfo;
|
||||||
Info: TTreeNodeInfo;
|
Info: TTreeNodeInfo;
|
||||||
Node: TTreeNode;
|
Node: TTreeNode;
|
||||||
|
lSelfAX: TLazAccessibleObject;
|
||||||
begin
|
begin
|
||||||
if Owner<>nil then Owner.ClearCache;
|
if Owner<>nil then Owner.ClearCache;
|
||||||
if StreamVersion=TTreeNodeWithPointerStreamVersion then
|
if StreamVersion=TTreeNodeWithPointerStreamVersion then
|
||||||
@ -1768,7 +1773,16 @@ begin
|
|||||||
SetLength(FText,Info.TextLen);
|
SetLength(FText,Info.TextLen);
|
||||||
end;
|
end;
|
||||||
if FText<>'' then
|
if FText<>'' then
|
||||||
|
begin
|
||||||
Stream.Read(FText[1],length(FText));
|
Stream.Read(FText[1],length(FText));
|
||||||
|
// Update accessibility information
|
||||||
|
if TreeView<>nil then
|
||||||
|
begin
|
||||||
|
lSelfAX := TreeView.GetAccessibleObject.GetChildAccessibleObjectWithDataObject(Self);
|
||||||
|
if lSelfAX <> nil then
|
||||||
|
lSelfAX.AccessibleValue := FText;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if Owner<>nil then begin
|
if Owner<>nil then begin
|
||||||
for I := 0 to ItemCount - 1 do begin
|
for I := 0 to ItemCount - 1 do begin
|
||||||
Node:=Owner.AddChild(Self, '');
|
Node:=Owner.AddChild(Self, '');
|
||||||
@ -2228,7 +2242,8 @@ begin
|
|||||||
if ok and (Owner<>nil) then
|
if ok and (Owner<>nil) then
|
||||||
begin
|
begin
|
||||||
lAccessibleObject := FOwner.GetAccessibleObject().AddChildAccessibleObject();
|
lAccessibleObject := FOwner.GetAccessibleObject().AddChildAccessibleObject();
|
||||||
lAccessibleObject.AccessibleDescription := S;
|
lAccessibleObject.AccessibleDescription := 'Item';
|
||||||
|
lAccessibleObject.AccessibleValue := S;
|
||||||
lAccessibleObject.AccessibleRole := larTreeItem;
|
lAccessibleObject.AccessibleRole := larTreeItem;
|
||||||
lAccessibleObject.DataObject := Result;
|
lAccessibleObject.DataObject := Result;
|
||||||
end;
|
end;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
{$define CarbonUseCocoa}
|
{$define CarbonUseCocoa}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{$ifndef VER2_2}{$ifndef VER2_4}{$ifndef CarbonDontUseCocoa}
|
||||||
|
{$define CarbonUseCocoaAll}
|
||||||
|
{$endif}{$endif}{$endif}
|
||||||
|
|
||||||
// Show debug info when tracing:
|
// Show debug info when tracing:
|
||||||
|
|
||||||
{off $define DebugBitmaps}
|
{off $define DebugBitmaps}
|
||||||
|
@ -33,6 +33,9 @@ uses
|
|||||||
Types, Classes, SysUtils, Math, Contnrs,
|
Types, Classes, SysUtils, Math, Contnrs,
|
||||||
// carbon bindings
|
// carbon bindings
|
||||||
MacOSAll,
|
MacOSAll,
|
||||||
|
{$ifdef CarbonUseCocoaAll}
|
||||||
|
CocoaAll,
|
||||||
|
{$endif}
|
||||||
// widgetset
|
// widgetset
|
||||||
WSControls, WSLCLClasses, WSProc,
|
WSControls, WSLCLClasses, WSProc,
|
||||||
// LCL Carbon
|
// LCL Carbon
|
||||||
|
@ -165,12 +165,17 @@ end;
|
|||||||
|
|
||||||
http://developer.apple.com/library/mac/#documentation/Accessibility/Reference/AccessibilityCarbonRef/Reference/reference.html
|
http://developer.apple.com/library/mac/#documentation/Accessibility/Reference/AccessibilityCarbonRef/Reference/reference.html
|
||||||
|
|
||||||
|
Documentation explaining in details which attributes are required for each Role:
|
||||||
|
|
||||||
|
http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Attributes.html
|
||||||
|
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function CarbonControl_Accessibility(ANextHandler: EventHandlerCallRef;
|
function CarbonControl_Accessibility(ANextHandler: EventHandlerCallRef;
|
||||||
AEvent: EventRef;
|
AEvent: EventRef;
|
||||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||||
var
|
var
|
||||||
lAXRole, lInputStr, lOutputStr: CFStringRef;
|
// Inputs
|
||||||
|
lAXRole, lInputStr: CFStringRef;
|
||||||
lInputAXObject: AXUIElementRef;
|
lInputAXObject: AXUIElementRef;
|
||||||
lInputID64: UInt64;
|
lInputID64: UInt64;
|
||||||
lInputAccessibleObject: TLazAccessibleObject;
|
lInputAccessibleObject: TLazAccessibleObject;
|
||||||
@ -178,9 +183,12 @@ var
|
|||||||
lInputMutableArray: CFMutableArrayRef;
|
lInputMutableArray: CFMutableArrayRef;
|
||||||
lInputHIPoint: HIPoint;
|
lInputHIPoint: HIPoint;
|
||||||
lInputPoint: TPoint;
|
lInputPoint: TPoint;
|
||||||
|
// Outputs
|
||||||
|
lOutputStr: CFStringRef;
|
||||||
lOutputBool: Boolean;
|
lOutputBool: Boolean;
|
||||||
lOutputInt: SInt64;
|
lOutputInt: SInt64;
|
||||||
lOutputNum: CFNumberRef;
|
lOutputNum: CFNumberRef;
|
||||||
|
//
|
||||||
lLazControl: TControl;
|
lLazControl: TControl;
|
||||||
lLazAXRole: TLazAccessibilityRole;
|
lLazAXRole: TLazAccessibilityRole;
|
||||||
Command: HICommandExtended;
|
Command: HICommandExtended;
|
||||||
@ -192,6 +200,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
lAccessibleObj: TLazAccessibleObject;
|
lAccessibleObj: TLazAccessibleObject;
|
||||||
lHandle: PtrInt;
|
lHandle: PtrInt;
|
||||||
|
lSelection: TLazAccessibleObject;
|
||||||
const SName = 'CarbonControl_Accessibility';
|
const SName = 'CarbonControl_Accessibility';
|
||||||
begin
|
begin
|
||||||
{$IF defined(VerboseControlEvent) or defined(VerboseAccessibilityEvent)}
|
{$IF defined(VerboseControlEvent) or defined(VerboseAccessibilityEvent)}
|
||||||
@ -209,15 +218,9 @@ begin
|
|||||||
// Check if this is an event to a child accessible object
|
// Check if this is an event to a child accessible object
|
||||||
AXUIElementGetIdentifier(lInputAXObject, lInputID64);
|
AXUIElementGetIdentifier(lInputAXObject, lInputID64);
|
||||||
if (lLazControl is TCustomControl) and (lInputID64 <> 0) then
|
if (lLazControl is TCustomControl) and (lInputID64 <> 0) then
|
||||||
begin
|
lInputAccessibleObject := TLazAccessibleObject(PtrInt(lInputID64))
|
||||||
lInputAccessibleObject := TLazAccessibleObject(PtrInt(lInputID64));
|
else lInputAccessibleObject := lLazControl.GetAccessibleObject();
|
||||||
lLazAXRole := lLazControl.AccessibleRole;
|
lLazAXRole := lInputAccessibleObject.AccessibleRole;
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
lInputAccessibleObject := lLazControl.GetAccessibleObject();
|
|
||||||
lLazAXRole := lLazControl.AccessibleRole;
|
|
||||||
end;
|
|
||||||
|
|
||||||
EventKind := GetEventKind(AEvent);
|
EventKind := GetEventKind(AEvent);
|
||||||
case EventKind of
|
case EventKind of
|
||||||
@ -234,9 +237,8 @@ begin
|
|||||||
// specified point, in the form of an AXUIElementRef.
|
// specified point, in the form of an AXUIElementRef.
|
||||||
lInputPoint := Types.Point(Round(lInputHIPoint.x), Round(lInputHIPoint.y));
|
lInputPoint := Types.Point(Round(lInputHIPoint.x), Round(lInputHIPoint.y));
|
||||||
lInputPoint := TWinControl(lLazControl).ScreenToClient(lInputPoint);
|
lInputPoint := TWinControl(lLazControl).ScreenToClient(lInputPoint);
|
||||||
lAccessibleObj := lLazControl.GetAccessibleObject();
|
if lInputAccessibleObject = nil then Exit;
|
||||||
if lAccessibleObj = nil then Exit;
|
lAccessibleObj := lInputAccessibleObject.GetChildAccessibleObjectAtPos(lInputPoint);
|
||||||
lAccessibleObj := lAccessibleObj.GetChildAccessibleObjectAtPos(lInputPoint);
|
|
||||||
if (lAccessibleObj = nil) or (lAccessibleObj.Handle = 0) then Exit;
|
if (lAccessibleObj = nil) or (lAccessibleObj.Handle = 0) then Exit;
|
||||||
lHandle := lAccessibleObj.Handle;
|
lHandle := lAccessibleObj.Handle;
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleChild, typeCFTypeRef,
|
SetEventParameter(AEvent, kEventParamAccessibleChild, typeCFTypeRef,
|
||||||
@ -266,7 +268,7 @@ begin
|
|||||||
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
end;
|
end;
|
||||||
// AXChildren
|
// AXChildren
|
||||||
lCount := lLazControl.GetAccessibleObject().GetChildAccessibleObjectsCount;
|
lCount := lInputAccessibleObject.GetChildAccessibleObjectsCount;
|
||||||
if lCount > 0 then
|
if lCount > 0 then
|
||||||
begin
|
begin
|
||||||
lOutputStr := CFSTR('AXChildren');
|
lOutputStr := CFSTR('AXChildren');
|
||||||
@ -280,6 +282,24 @@ begin
|
|||||||
lOutputStr := CFSTR('AXNumberOfCharacters');
|
lOutputStr := CFSTR('AXNumberOfCharacters');
|
||||||
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
end;
|
end;
|
||||||
|
// Now elements for each role
|
||||||
|
// AXList
|
||||||
|
if (lLazControl is TCustomControl) and
|
||||||
|
(lLazAXRole in [larListBox, larTreeView]) then
|
||||||
|
begin
|
||||||
|
lOutputStr := CFSTR('AXOrientation');
|
||||||
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
|
lOutputStr := CFSTR('AXSelectedChildren');
|
||||||
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
|
lOutputStr := CFSTR('AXVisibleChildren');
|
||||||
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
|
end;
|
||||||
|
// Basic elements for non-windowed accessible objects
|
||||||
|
if (lLazControl is TCustomControl) and (lInputID64 <> 0) then
|
||||||
|
begin
|
||||||
|
lOutputStr := CFSTR('AXValue');
|
||||||
|
CFArrayAppendValue(lInputMutableArray, lOutputStr);
|
||||||
|
end;
|
||||||
end; // kEventAccessibleGetAllAttributeNames
|
end; // kEventAccessibleGetAllAttributeNames
|
||||||
kEventAccessibleGetAllParameterizedAttributeNames:
|
kEventAccessibleGetAllParameterizedAttributeNames:
|
||||||
begin
|
begin
|
||||||
@ -321,12 +341,14 @@ begin
|
|||||||
|
|
||||||
lInputPasStr := CFStringToStr(lInputStr);
|
lInputPasStr := CFStringToStr(lInputStr);
|
||||||
|
|
||||||
|
{$IF defined(VerboseControlEvent) or defined(VerboseAccessibilityEvent)}
|
||||||
|
DebugLn('CarbonControl_Accessibility kEventAccessibleGetNamedAttribute kEventParamAccessibleAttributeName=' + lInputPasStr);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
// AXRole overrides TCustomControl and TCustomWindow values
|
// AXRole overrides TCustomControl and TCustomWindow values
|
||||||
if lInputPasStr = 'AXRole' then
|
if lInputPasStr = 'AXRole' then
|
||||||
begin
|
begin
|
||||||
if (lLazControl is TWinControl) and (not (lLazControl is TCustomForm))
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
and (not (lLazControl is TCustomControl)) then Exit;
|
|
||||||
|
|
||||||
case lLazAXRole of
|
case lLazAXRole of
|
||||||
larAnimation: lAXRole := CFSTR('AXImage');
|
larAnimation: lAXRole := CFSTR('AXImage');
|
||||||
larButton: lAXRole := CFSTR('AXButton');
|
larButton: lAXRole := CFSTR('AXButton');
|
||||||
@ -366,36 +388,31 @@ begin
|
|||||||
|
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end
|
||||||
// Specially only AXRoleDescription is allowed to override non-TCustomControl values
|
// Specially only AXRoleDescription is allowed to override non-TCustomControl values
|
||||||
if lInputPasStr = 'AXRoleDescription' then
|
else if lInputPasStr = 'AXRoleDescription' then
|
||||||
begin
|
begin
|
||||||
if lLazControl.AccessibleDescription = '' then Exit;
|
if lInputAccessibleObject.AccessibleDescription = '' then Exit;
|
||||||
CreateCFString(lLazControl.AccessibleDescription, lOutputStr);
|
CreateCFString(lInputAccessibleObject.AccessibleDescription, lOutputStr);
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFStringRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFStringRef,
|
||||||
SizeOf(CFStringRef), @lOutputStr);
|
SizeOf(CFStringRef), @lOutputStr);
|
||||||
FreeCFString(lOutputStr);
|
FreeCFString(lOutputStr);
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end
|
||||||
|
else if lInputPasStr = 'AXValue' then
|
||||||
if not (lLazControl is TCustomControl) then Exit;
|
|
||||||
|
|
||||||
{$IF defined(VerboseControlEvent) or defined(VerboseAccessibilityEvent)}
|
|
||||||
DebugLn('CarbonControl_Accessibility kEventAccessibleGetNamedAttribute kEventParamAccessibleAttributeName=' + lInputPasStr);
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{ else if lInputPasStr = 'AXValue' then
|
|
||||||
begin
|
begin
|
||||||
if lLazControl.AccessibleValue = '' then Exit;
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
CreateCFString(lLazControl.AccessibleValue, lOutputStr);
|
if (lInputID64 = 0) then Exit;
|
||||||
|
CreateCFString(lInputAccessibleObject.AccessibleValue, lOutputStr);
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFStringRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFStringRef,
|
||||||
SizeOf(CFStringRef), @lOutputStr);
|
SizeOf(CFStringRef), @lOutputStr);
|
||||||
FreeCFString(lOutputStr);
|
FreeCFString(lOutputStr);
|
||||||
end}
|
end
|
||||||
if (lInputPasStr = 'AXNumberOfCharacters') then
|
else if (lInputPasStr = 'AXNumberOfCharacters') then
|
||||||
begin
|
begin
|
||||||
lOutputInt := UTF8Length(lLazControl.AccessibleValue);
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
|
lOutputInt := UTF8Length(lInputAccessibleObject.AccessibleValue);
|
||||||
lOutputNum := CFNumberCreate(nil, kCFNumberSInt64Type, @lOutputInt);
|
lOutputNum := CFNumberCreate(nil, kCFNumberSInt64Type, @lOutputInt);
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFNumberRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFNumberRef,
|
||||||
SizeOf(lOutputNum), @lOutputNum);
|
SizeOf(lOutputNum), @lOutputNum);
|
||||||
@ -405,25 +422,25 @@ begin
|
|||||||
//
|
//
|
||||||
// Parameterized attributes
|
// Parameterized attributes
|
||||||
//
|
//
|
||||||
else if (lLazControl is TCustomControl) and (lInputPasStr = 'AXStringForRange') then
|
else if (lInputPasStr = 'AXStringForRange') then
|
||||||
begin
|
begin
|
||||||
if lLazControl.AccessibleValue = '' then Exit;
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
CreateCFString(lLazControl.AccessibleValue, lOutputStr);
|
if lInputAccessibleObject.AccessibleValue = '' then Exit;
|
||||||
|
CreateCFString(lInputAccessibleObject.AccessibleValue, lOutputStr);
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeParameter, typeCFStringRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeParameter, typeCFStringRef,
|
||||||
SizeOf(CFStringRef), @lOutputStr);
|
SizeOf(CFStringRef), @lOutputStr);
|
||||||
FreeCFString(lOutputStr);
|
FreeCFString(lOutputStr);
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
end
|
end
|
||||||
else if (lLazControl is TCustomControl) and
|
else if (lInputPasStr = 'AXAttributedStringForRange') or
|
||||||
((lInputPasStr = 'AXAttributedStringForRange') or
|
|
||||||
(lInputPasStr = 'AXBoundsForRange') or
|
(lInputPasStr = 'AXBoundsForRange') or
|
||||||
(lInputPasStr = 'AXRangeForIndex') or
|
(lInputPasStr = 'AXRangeForIndex') or
|
||||||
(lInputPasStr = 'AXRangeForLine') or
|
(lInputPasStr = 'AXRangeForLine') or
|
||||||
(lInputPasStr = 'AXRangeForPosition') or
|
(lInputPasStr = 'AXRangeForPosition') or
|
||||||
(lInputPasStr = 'AXRTFForRange') or
|
(lInputPasStr = 'AXRTFForRange') or
|
||||||
(lInputPasStr = 'AXStyleRangeForIndex')
|
(lInputPasStr = 'AXStyleRangeForIndex') then
|
||||||
) then
|
|
||||||
begin
|
begin
|
||||||
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeParameter, typeCFTypeRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeParameter, typeCFTypeRef,
|
||||||
0, nil);
|
0, nil);
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
@ -431,6 +448,7 @@ begin
|
|||||||
//if (CFStringCompare(lInputStr, kAXFocusedAttribute, 0) = kCFCompareEqualTo) then
|
//if (CFStringCompare(lInputStr, kAXFocusedAttribute, 0) = kCFCompareEqualTo) then
|
||||||
else if lInputPasStr = 'AXFocused' then
|
else if lInputPasStr = 'AXFocused' then
|
||||||
begin
|
begin
|
||||||
|
//if not (lLazControl is TCustomControl) then Exit;
|
||||||
if not (lLazControl is TWinControl) then lOutputBool := False
|
if not (lLazControl is TWinControl) then lOutputBool := False
|
||||||
else if TWinControl(lLazControl).Focused then lOutputBool := True
|
else if TWinControl(lLazControl).Focused then lOutputBool := True
|
||||||
else lOutputBool := False;
|
else lOutputBool := False;
|
||||||
@ -444,24 +462,61 @@ begin
|
|||||||
|
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
end
|
end
|
||||||
else if (CFStringCompare(lInputStr, CFSTR('AXChildren'), 0) = kCFCompareEqualTo) then // kAXChildrenAttribute
|
//else if (CFStringCompare(lInputStr, CFSTR('AXChildren'), 0) = kCFCompareEqualTo) then // kAXChildrenAttribute
|
||||||
|
else if (lInputPasStr = 'AXChildren') or (lInputPasStr = 'AXVisibleChildren')
|
||||||
|
or (lInputPasStr = 'AXSelectedChildren') then
|
||||||
begin
|
begin
|
||||||
if not (lLazControl is TCustomControl) then Exit;
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
|
|
||||||
// Create and return an array of AXUIElements describing the children of this view.
|
// Create and return an array of AXUIElements describing the children of this view.
|
||||||
lCount := lLazControl.GetAccessibleObject().GetChildAccessibleObjectsCount;
|
if (lInputPasStr = 'AXSelectedChildren') then
|
||||||
|
begin
|
||||||
|
lSelection := lInputAccessibleObject.GetSelectedChildAccessibleObject();
|
||||||
|
if lSelection = nil then
|
||||||
|
lArray := CFArrayCreateMutable(kCFAllocatorDefault, 0, @kCFTypeArrayCallBacks)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
lArray := CFArrayCreateMutable(kCFAllocatorDefault, 1, @kCFTypeArrayCallBacks);
|
||||||
|
lElement := AXUIElementRef(lSelection.Handle);
|
||||||
|
if lElement <> nil then
|
||||||
|
CFArrayAppendValue(lArray, lElement);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
lCount := lInputAccessibleObject.GetChildAccessibleObjectsCount;
|
||||||
lArray := CFArrayCreateMutable(kCFAllocatorDefault, lCount, @kCFTypeArrayCallBacks);
|
lArray := CFArrayCreateMutable(kCFAllocatorDefault, lCount, @kCFTypeArrayCallBacks);
|
||||||
for i := 0 to lCount - 1 do
|
for i := 0 to lCount - 1 do
|
||||||
begin
|
begin
|
||||||
lElement := AXUIElementRef(lLazControl.GetAccessibleObject().Handle);
|
lElement := AXUIElementRef(lInputAccessibleObject.Handle);
|
||||||
if lElement <> nil then
|
if lElement <> nil then
|
||||||
CFArrayAppendValue(lArray, lElement);
|
CFArrayAppendValue(lArray, lElement);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFTypeRef,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFTypeRef,
|
||||||
SizeOf(lArray), @lArray);
|
SizeOf(lArray), @lArray);
|
||||||
CFRelease(lArray);
|
CFRelease(lArray);
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
|
end
|
||||||
|
else if lInputPasStr = 'AXOrientation' then
|
||||||
|
begin
|
||||||
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
|
{$ifdef CarbonUseCocoaAll}
|
||||||
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeParameter, typeCFStringRef,
|
||||||
|
SizeOf(CFStringRef), @NSAccessibilityHorizontalOrientationValue);
|
||||||
|
Result := noErr;
|
||||||
|
{$endif}
|
||||||
|
end
|
||||||
|
else if lInputPasStr = 'AXParent' then
|
||||||
|
begin
|
||||||
|
if lInputID64 = 0 then Exit;
|
||||||
|
if not (lLazControl is TCustomControl) then Exit;
|
||||||
|
if lInputAccessibleObject.Parent = nil then Exit;
|
||||||
|
lElement := AXUIElementRef(lInputAccessibleObject.Parent.Handle);
|
||||||
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeValue, typeCFTypeRef,
|
||||||
|
SizeOf(AXUIElementRef), @lElement);
|
||||||
|
Result := noErr;
|
||||||
end;
|
end;
|
||||||
end; // kEventAccessibleGetNamedAttribute
|
end; // kEventAccessibleGetNamedAttribute
|
||||||
kEventAccessibleIsNamedAttributeSettable:
|
kEventAccessibleIsNamedAttributeSettable:
|
||||||
@ -475,18 +530,22 @@ begin
|
|||||||
|
|
||||||
lInputPasStr := CFStringToStr(lInputStr);
|
lInputPasStr := CFStringToStr(lInputStr);
|
||||||
|
|
||||||
{ // Now elements for each role
|
if (lInputPasStr = 'AXFocused') then
|
||||||
// AXStaticText
|
begin
|
||||||
if lLazAXRole in [larClock, larLabel, larListItem, larTreeItem] then
|
lOutputBool := TCustomControl(lLazControl).TabStop;
|
||||||
begin}
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeSettable, typeBoolean,
|
||||||
if (lInputPasStr = 'AXFocused') or (lInputPasStr = 'AXStringForRange') or
|
SizeOf(Boolean), @lOutputBool);
|
||||||
(lInputPasStr = 'AXNumberOfCharacters') then
|
Result := noErr;
|
||||||
|
end
|
||||||
|
else if (lInputPasStr = 'AXStringForRange') or
|
||||||
|
(lInputPasStr = 'AXNumberOfCharacters') or (lInputPasStr = 'AXChildren') or
|
||||||
|
(lInputPasStr = 'AXSelectedChildren') or (lInputPasStr = 'AXVisibleChildren') then
|
||||||
begin
|
begin
|
||||||
lOutputBool := False;
|
lOutputBool := False;
|
||||||
SetEventParameter(AEvent, kEventParamAccessibleAttributeSettable, typeBoolean,
|
SetEventParameter(AEvent, kEventParamAccessibleAttributeSettable, typeBoolean,
|
||||||
SizeOf(Boolean), @lOutputBool);
|
SizeOf(Boolean), @lOutputBool);
|
||||||
Result := noErr;
|
Result := noErr;
|
||||||
end
|
end;
|
||||||
end; // kEventAccessibleIsNamedAttributeSettable
|
end; // kEventAccessibleIsNamedAttributeSettable
|
||||||
end; // case EventKind of
|
end; // case EventKind of
|
||||||
end;
|
end;
|
||||||
|
@ -136,7 +136,8 @@ begin
|
|||||||
// Requesting a handle allocation here might be too soon and crash, so cancel the whole action
|
// Requesting a handle allocation here might be too soon and crash, so cancel the whole action
|
||||||
if not lWinControl.HandleAllocated then Exit;
|
if not lWinControl.HandleAllocated then Exit;
|
||||||
|
|
||||||
if (AObject.OwnerControl <> nil) and (AObject.OwnerControl is TWinControl) then
|
if (AObject.OwnerControl <> nil) and (AObject.OwnerControl is TWinControl) and
|
||||||
|
(AObject.OwnerControl.GetAccessibleObject() = AObject) then
|
||||||
begin
|
begin
|
||||||
lControlHandle := TCarbonControl(TWinControl(AObject.OwnerControl).Handle);
|
lControlHandle := TCarbonControl(TWinControl(AObject.OwnerControl).Handle);
|
||||||
AHIObject := lControlHandle.Widget;
|
AHIObject := lControlHandle.Widget;
|
||||||
@ -164,6 +165,7 @@ begin
|
|||||||
if lHIObject = nil then Exit;
|
if lHIObject = nil then Exit;
|
||||||
|
|
||||||
lElement := AXUIElementCreateWithHIObjectAndIdentifier(lHIObject, lID64);
|
lElement := AXUIElementCreateWithHIObjectAndIdentifier(lHIObject, lID64);
|
||||||
|
Result := HWND(lElement);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCarbonWSLazAccessibleObject.DestroyHandle(
|
class procedure TCarbonWSLazAccessibleObject.DestroyHandle(
|
||||||
|
Loading…
Reference in New Issue
Block a user