Sign in Join
Wiki copytemporary

LCL Accessibility: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: LCL Accessibility

OldNewLine
1+Accessibility means planning and developing applications in a way in which allows an individual with visual impairments or other disabilities to perform a task that they would otherwise be unable to do, or increase the ease and safety with which a task can be performed, or anything that assists individuals to carry-out daily activities.
2+
3+# LCL Accessibility Introduction
4+
5+The LCL should automatically provide accessibility for all of its standard controls, or allow the underlying widgetset to provide its own accessibility for the controls utilized directly from the widgetset. LCL users need to provide accessibility only for TCustomControl descendents introduced in the application. LCL developers need to provide accessibility for all TCustomControl descendents in the LCL and also for all non-windowed controls in the LCL (such as TLabel).
6+
7+The accessibility information provided is a tree of accessible objects which represent the controls hierarchy in the application and which can cover both windowed and non-windowed controls. What the screen reader does exactly with this information is theoretically up to it to decide, but of course it is necessary to test to verify if the most popular screen readers are actually using the information provided in the expected way. The LCL is responsible for making these bridges, since it provides a quite simple accessibility interface. Platform APIs, especially the one from macOS, are more complex.
8+
9+TControl will automatically create an accessible object and place it correctly in the accessible objects tree, so it is not necessary to manually create accessible objects unless a control has sub-items which should be represented individually and are not TControl-descendents. One typical example are the items of the TTreeView control. They are not controls, but can be selected individually and therefore each item should be an accessible object on its own.
10+
11+``` pascal
12+ TLazAccessibilityRole = (
13+ larAnimation, // An object that displays an animation.
14+ larButton, // A button.
15+ larCell, // A cell in a table.
16+ larChart, // An object that displays a graphical representation of data.
17+ larCheckBox, // An object that can be checked or unchecked, or sometimes in an intermediary state
18+ larClock, // A clock displaying time.
19+ larColorPicker, // A control which allows selecting a color.
20+ larComboBox, // A list of choices that the user can select from.
21+ larDateField, // A controls which displays and possibly allows to choose a date.
22+ larGrid, // A grid control which displays cells
23+ larGroup, // A control which groups others, such as a TGroupBox.
24+ larIgnore, // Something to be ignored. For example a blank space between other objects.
25+ larImage, // A graphic or picture or an icon.
26+ larLabel, // A text label as usually placed near other widgets.
27+ larListBox, // A list of items, from which the user can select one or more items.
28+ larListItem, // An item in a list of items.
29+ larMenuBar, // A main menu bar.
30+ larMenuItem, // A item in a menu.
31+ larProgressIndicator, // A control which shows a progress indication.
32+ larResizeGrip, // A grip that the user can drag to change the size of widgets.
33+ larScrollBar, // A control to scroll another one
34+ larSpinner, // A control which allows to increment / decrement a value.
35+ larTabControl, // A control with tabs, like TPageControl.
36+ larTextEditorMultiline, // A multi-line text editor (for example: TMemo, SynEdit)
37+ larTextEditorSingleline, // A single-line text editor (for example: TEdit)
38+ larTrackBar, // A control which allows to drag a slider.
39+ larTreeView, // A list of items in a tree structure.
40+ larTreeItem, // An item in a tree structure.
41+ larWindow // A top level window.
42+ );
43+
44+ // The Child Accessible Objects are designed for non-TControl children
45+ // of a TCustomControl descendent, for example the items of a TTreeView
46+
47+ { TLazAccessibleObject }
48+
49+ TLazAccessibleObject = class
50+ private
51+ FHandle: PtrInt;
52+ FPosition: TPoint;
53+ FSize: TSize;
54+ function GetHandle: PtrInt;
55+ function GetPosition: TPoint;
56+ function GetSize: TSize;
57+ procedure SetPosition(AValue: TPoint);
58+ procedure SetSize(AValue: TSize);
59+ protected
60+ FChildren: TFPList; // of TLazAccessibleObject
61+ FAccessibleDescription: TCaption;
62+ FAccessibleValue: TCaption;
63+ FAccessibleRole: TLazAccessibilityRole;
64+ class procedure WSRegisterClass; virtual;//override;
65+ public
66+ OwnerControl: TControl;
67+ Parent: TLazAccessibleObject;
68+ DataObject: TObject; // Available to be used to connect to an object
69+ SecondaryHandle: PtrInt; // Available for Widgetsets to use
70+ constructor Create(AOwner: TControl); virtual;
71+ destructor Destroy; override;
72+ procedure SetAccessibleDescription(const ADescription: TCaption);
73+ procedure SetAccessibleValue(const AValue: TCaption);
74+ procedure SetAccessibleRole(const ARole: TLazAccessibilityRole);
75+ function FindOwnerWinControl: TWinControl;
76+ function AddChildAccessibleObject: TLazAccessibleObject; virtual;
77+ procedure ClearChildAccessibleObjects;
78+ procedure RemoveChildAccessibleObject(AObject: TLazAccessibleObject);
79+ function GetChildAccessibleObject(AIndex: Integer): TLazAccessibleObject;
80+ function GetChildAccessibleObjectWithDataObject(ADataObject: TObject): TLazAccessibleObject;
81+ function GetChildAccessibleObjectsCount: Integer;
82+ function GetSelectedChildAccessibleObject: TLazAccessibleObject; virtual;
83+ function GetChildAccessibleObjectAtPos(APos: TPoint): TLazAccessibleObject; virtual;
84+ // Primary information
85+ property AccessibleDescription: TCaption read FAccessibleDescription write SetAccessibleDescription;
86+ property AccessibleValue: TCaption read FAccessibleValue write SetAccessibleValue;
87+ property AccessibleRole: TLazAccessibilityRole read FAccessibleRole write SetAccessibleRole;
88+ property Position: TPoint read GetPosition write SetPosition;
89+ property Size: TSize read GetSize write SetSize;
90+ property Handle: PtrInt read GetHandle write FHandle;
91+ end;
92+
93+ TControl = class(TLCLComponent)
94+ private
95+...
96+ // accessibility
97+ function GetAccessibleObject: TLazAccessibleObject;
98+ function CreateAccessibleObject: TLazAccessibleObject; virtual;
99+ function GetSelectedChildAccessibleObject: TLazAccessibleObject; virtual;
100+ function GetChildAccessibleObjectAtPos(APos: TPoint): TLazAccessibleObject; virtual;
101+ public
102+ // standard properties, which should be supported by all descendants
103+ property AccessibleDescription: TCaption read GetAccessibleDescription write SetAccessibleDescription;
104+ property AccessibleValue: TCaption read GetAccessibleValue write SetAccessibleValue;
105+ property AccessibleRole: TLazAccessibilityRole read GetAccessibleRole write SetAccessibleRole;
106+...
107+ end;
108+```
109+
110+## Obtaining the accessible object associated with a control
111+
112+Use TControl.GetAccessibleObject: TLazAccessibleObject;
113+
114+## Setting the basic accessible fields for a control
115+
116+Use TControl.AcessibleDescription, TControl.AccessibleValue, TControl.AccessibleRole. TControl.GetAccessibleObject().AccessibleDescription is the same thing as TControl.AccessibleDescription and they are connected.
117+
118+# Screen Readers
119+
120+The first step in testing screen reader support is installing one and being able to use it to check what users will see when using your application.
121+
122+## macOS VoiceOver
123+
124+The screen reader for the vast majority of users in macOS is VoiceOver which comes pre-installed with the operating system. To activate it go to System Preferences \> Accessibility and turn VoiceOver on. It couldnt be any simpler. Using it is also mostly easy and intuitive.
125+
126+<figure>
127+<img src="Voiceover_screenshot.png" title="Voiceover_screenshot.png" width="800" />
128+<figcaption>Voiceover_screenshot.png</figcaption>
129+</figure>
130+
131+## Orca for Linux
132+
133+Orca is currently the most popular screen reader in Linux for both GNOME and KDE. See: <http://en.wikipedia.org/wiki/Orca_(assistive_technology)>
134+
135+# Speech synthesis
136+
137+An intelligible text-to-speech program allows individuals with visual impairments or reading disabilities to listen to written words on their computer. See the [[Speech Synthesis]] article for details of cross-platform and native operating system solutions.
138+
139+# Accessibility Inspector Tools
140+
141+Accessibility inspectors can help a lot at checking if the application is giving correct information.
142+
143+## macOS
144+
145+In /Applications/Xcode.app/Contents/Applications/ there is an Accessibility Inspector application which will be very useful when developing in this platform.
146+
147+See also:
148+
149+- Apple's [macOS accessibility documentation](https://developer.apple.com/accessibility/macos/)
150+- Apple's [Using the Accessibility Inspector](https://developer.apple.com/library/archive/documentation/Accessibility/Conceptual/AccessibilityMacOSX/OSXAXTestingApps.html)
151+
152+# Accessibility APIs
153+
154+## Carbon
155+
156+Search Google for:
157+
158+`site:developer.apple.com carbon accessibility`
159+
160+The main accessibility code for Carbon is in lcl/interfaces/carbon/carbonprivatecontrol.inc in the function CarbonControl_Accessibility
161+
162+The events for this handler are:
163+
164+- kEventAccessibleGetChildAtPoint
165+- kEventAccessibleGetFocusedChild
166+- kEventAccessibleGetAllAttributeNames
167+- kEventAccessibleGetAllParameterizedAttributeNames
168+- kEventAccessibleGetNamedAttribute
169+- kEventAccessibleSetNamedAttribute
170+- kEventAccessibleIsNamedAttributeSettable
171+- kEventAccessibleGetAllActionNames
172+- kEventAccessiblePerformNamedAction
173+- kEventAccessibleGetNamedActionDescription
174+
175+For kEventAccessibleGetNamedAttribute the main named attributes are:
176+
177+- AXRole
178+- AXRoleDescription
179+- AXDescription
180+- AXHelp
181+- AXParent
182+- AXChildren
183+- AXWindow
184+- AXTopLevelUIElement
185+- AXEnabled
186+- AXSize
187+- AXPosition
188+
189+And besides the ones listed here there are tons more. See which attributes each role should implement here: [http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Role.html#//apple_ref/doc/uid/TP40007870-Roles-AXStaticText](http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Role.html#//apple_ref/doc/uid/TP40007870-Roles-AXStaticText)
190+
191+Table explaining the events: <http://developer.apple.com/library/mac/#documentation/Accessibility/Reference/AccessibilityCarbonRef/Reference/reference.html>
192+
193+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>
194+
195+List of routines to handle a AXUIElementRef: <http://developer.apple.com/library/mac/#documentation/Accessibility/Reference/AccessibilityLowlevel/AXUIElement_h/CompositePage.html>
196+
197+## Cocoa
198+
199+- Apple [Accessibility Programming Guide](https://developer.apple.com/library/archive/documentation/Accessibility/Conceptual/AccessibilityMacOSX/index.html)
200+- Apple docs for the [NSAccessibility Protocol](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSAccessibility_Protocol/Reference/Reference.html)
201+- Apple docs for [Accessibility Roles and Attributes Reference](http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Notifications.html)
202+
203+## Microsoft Active Accessibility
204+
205+See: <http://en.wikipedia.org/wiki/Microsoft_Active_Accessibility>
206+
207+Also: <http://www.stevetrefethen.com/blog/UsingtheMSAAIAccessibleinterfacewithinaDelphiApplication.aspx>
208+
209+Concrete code from MS: <http://msdn.microsoft.com/en-us/library/windows/desktop/cc307844.aspx>
210+
211+## AT-SPI for Linux
212+
213+See: <http://en.wikipedia.org/wiki/AT-SPI>
214+
215+For making an application support AT-SPI there are two solutions:
216+
217+1-\> Make the application a DBus server and serve the interface described in the following XML files: <http://git.gnome.org/browse/at-spi2-core/tree/xml>
218+
219+2-\> Use libatk, but this library requires a GLib main loop
220+
221+## Qt
222+
223+See: <http://doc.qt.nokia.com/4.3/qaccessiblewidget.html>
224+
225+Also: <http://doc.qt.nokia.com/4.3/qaccessible.html#Role-enum>
226+
227+Also: <http://doc.qt.nokia.com/qq/qq24-accessibility.html>
228+
229+## Concepts mapping
230+
231+| TLazAccessibleObject | Qt | macOS | MSAA | AT-SPI | Comments |
232+|----|----|----|----|----|----|
233+| AccessibleRole | QAccessible::Role | AXRole | Role | ?\|\|- | |
234+| AccessibleDescription | QAccessibleWidget::setDescription | AXRoleDescription, AXDescription, AXTitleUIElement | ? | ?\|\|- | |
235+| AccessibleValue | QAccessibleWidget::setValue | AXValue | Value, Name, State | ?\|\|- | |
236+| Position | ? | AXPosition | ? | ?\|\|- | |
237+| Size | ? | AXSize | ? | ?\|\|- | |
238+| Handle | ? | AXUIElementRef | ? | ?\|\|- | |
239+| Parent | ? | AXParent | ? | ?\|\|- | |
240+| SecondaryHandle | Vacant | Vacant | Vacant | Vacant\|\|- | |
241+
242+---
243+*From the Free Pascal wiki, page "LCL Accessibility", as it stood on 2021-02-24 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
244+Category: Accessibility
245+Category: GUI
246+Category: LCL
247+Category: Linux
248+Category: Windows
249+Category: macOS

Back to history