Feniks888 0 Posted October 2 Hello everyone, I'm currently working on a Delphi FMX application and need to improve its accessibility features for interactive elements. Specifically, I want to set the contentDescription for a TImage component, so that it can be properly identified by Google accessibility programs, allowing visually impaired users to interact with it effectively. Could someone please guide me on how to set the contentDescription for an existing TImage component on my form? Any examples or best practices for implementing accessibility in Delphi FMX would be greatly appreciated! Thank you in advance for your help! Share this post Link to post
Feniks888 0 Posted October 2 (edited) I found some information on this topic here: https://support.google.com/accessibility/android/answer/7158690 but I’m unsure how to apply it in Delphi FMX. Could anyone provide guidance on how to implement the contentDescription for interactive elements like TImage in Delphi based on this information? Edited October 2 by Feniks888 Share this post Link to post
Lajos Juhász 293 Posted October 2 I believe this is still the situation. Share this post Link to post
Feniks888 0 Posted October 2 3 hours ago, Lajos Juhász said: Я вважаю, що це все ще така ситуація. Thank you for your response. Share this post Link to post
Rollo62 536 Posted October 4 (edited) Maybe that can give some ideas, although for Win and VCL. https://stackoverflow.com/questions/38273974/delphi-components-and-screen-readers Perhaps this can be implemented in similar ways on Android too? But I doubt it will be already well prepared under FMX, habe not checked recently. Edit: Maybe you can check, if this might work for you ( untested ) : But I doubt that the Delphi handle works as expected. uses System.SysUtils, FMX.Types, FMX.Controls, FMX.Platform, FMX.Platform.Android, Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, Androidapi.JNI.Widget; ... procedure SetControlAccessibilityDescription(AControl: TControl; const ADescription: string); var NativeView: JView; begin NativeView := WindowHandleToPlatform(AControl.Handle).View; if NativeView <> nil then begin NativeView.setContentDescription(StringToJString(ADescription)); end else begin raise Exception.Create('Das View-Objekt konnte nicht abgerufen werden.'); end; end; ... // Application for Label SetControlAccessibilityDescription(Label1, 'Das ist eine Beschriftung für den Namen'); ... // Application for Edit SetControlAccessibilityDescription(Edit1, 'Bitte geben Sie Ihren Namen ein'); ... // Application for Checkbox SetControlAccessibilityDescription(CheckBox1, 'Ich akzeptiere die Nutzungsbedingungen'); ... // Application for Switch SetControlAccessibilityDescription(Switch1, 'Benachrichtigungen ein- oder ausschalten'); Edited October 4 by Rollo62 Share this post Link to post
Feniks888 0 Posted October 7 Thank you very much for the code, I'll try it today and let you know if it worked. Share this post Link to post
Dave Nottage 557 Posted October 8 On 10/4/2024 at 4:02 PM, Rollo62 said: NativeView := WindowHandleToPlatform(AControl.Handle).View; This part will not even compile. TControl does not have a Handle property in FMX. On 10/4/2024 at 4:02 PM, Rollo62 said: NativeView.setContentDescription(StringToJString(ADescription)); Nor will this. setContentDescription takes a JCharSequence as the parameter. The main problem is that "non-native" FMX controls do not have an underlying native control, except when ControlType is Platform. Even then, there is no support for calling setContentDescription on that native control. This would require adding a ContentDescription property to TControl so that it can be passed to the underlying "native" controls. On top of this, only certain controls on Android support ControlType of Platform. Share this post Link to post