FireMonkey Accessibility Package
Go Up to FireMonkey
FireMonkey desktop accessibility support is available for Delphi Tokyo for Win32, Win64, and OS X applications. The FireMonkey accessibility package is available as a download on the Registered Users site:
https://cc.embarcadero.com/Item/30780
The FireMonkey accessibility package supports:
- The JAWS screen reader from Freedom Scientific on Windows
- The VoiceOver screen reader from Apple on OS X
Contents
Technology
FireMonkey accessibility support is based on the Microsoft MSAA interface on Windows (Microsoft Active Accessibility architecture) and for OS X, it is based on the OS X accessibility protocol.
Information on the APIs can be found at:
- MSAA:
- OS X Accessibility:
The Windows MSAA implementation has been tested with Freedom Scientific JAWS and Microsoft Windows Narrator. On OS X, it has been tested against the Apple VoiceOver applications.
Architecture
To implement the operating system accessibility interfaces, a new form class is derived from the default FireMonkey TForm. This form class TAccForm has a separate implementation for the Windows platform target that implements the Windows MSAA interface and deals with all interaction of MSAA and FireMonkey controls on the form, and it also has its counterpart implementation for OS X.
This TAccForm class has built-in handling for the most common and standard FireMonkey controls. This means that other than descending forms from TAccForm instead of TForm, you have no extra steps to take to enable accessibility in FireMonkey applications.
Getting Started
To enable a multi-device form for accessibility, first add the required units that implement this. Accessibility comes in three units:
- FMX.ScreenReader
- FMX.ScreenReader.Mac
- FMX.ScreenReader.Win.
The uses list as such becomes:
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti,
System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms,
FMX.Dialogs, FMX.StdCtrls, FMX.ScreenReader
{$IFDEF MACOS}
, FMX.ScreenReader.Mac
{$ELSE}
, FMX.ScreenReader.Win
{$ENDIF}
;
Next, descend the form from TAccForm, instead of TForm:
type
TForm1 = class(TAccForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Supported Controls
The FireMonkey accessibility implementation has built-in support for following FireMonkey standard controls:
FireMonkey Control | Accessibility Class |
---|---|
TButton |
PUSHBUTTON |
TSpeedButton |
PUSHBUTTON |
TTracker |
SLIDER |
TEdit |
TEXT |
TListBox |
LIST |
TComboBox |
COMBOBOX |
TComboEdit |
COMBOBOX |
TSpinBox |
SPINBUTTON |
TLabel |
STATICTEXT |
TCheckBox |
CHECKBUTTON |
TRadioButton |
RADIOBUTTON |
TMainMenu |
MENU |
TMemo |
TEXT |
TTreeView |
OUTLINE ITEM |
TCustomGrid |
CELL |
When you use any of these controls in your FireMonkey application, there are no extra steps to take. The TAccForm properly allows the used screenreader software to read the control's text or state. Note also that all controls descending from these standard FireMonkey controls also automatically inherit the accessibility support.
Adding Accessibility Support to FireMonkey Custom Controls
To add support for a custom control for accessibility, add the interface IFMXAccessibility to your control and implement it.
IFMXAccessibility is defined as:
// Interface for custom controls to add accessibility support IFMXAccessibility = interface ['{49AF90E5-341A-4869-9D3E-F659670FB4D8}'] // Return the text to read by the accessibility interface function GetControlText: string; // Returns the accesibility role of the custom control function GetRole: TFMXRole; end;
This interface consists of two simple methods:
- GetRole: returns the role of the custom control
- GetControlText: returns the text the screenreader should voice when the control has focus
The TFMXRole type is defined as:
TFMXRole = (rStaticText, rCell, rText, rButton, rCheckBox, rRadioButton, rGrid, rList, rSlider, rComboBox, rTabGroup);
For a custom edit control (that does not descend from a standard FireMonkey edit control that already has accessibility support), this can be implemented as:
type
TMyOwnFireMonkeyEdit = class(TControl, IFMXAccessibility)
protected
function GetControlText: string;
function GetRole: TFMXRole;
end;
implementation
{ TMyOwnFireMonkeyEdit }
function TMyOwnFireMonkeyEdit.GetControlText: string;
begin
Result := GetMyControlText,
end;
function TMyOwnFireMonkeyEdit.GetRole: TFMXRole;
begin
Result := rText;
end;