| 
									
										
										
										
											2016-08-22 16:27:33 -07:00
										 |  |  | # Accessibility
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-19 17:36:49 -06:00
										 |  |  | Accessibility concerns in Electron applications are similar to those of | 
					
						
							| 
									
										
										
										
											2021-10-27 19:17:43 -07:00
										 |  |  | websites because they're both ultimately HTML. | 
					
						
							| 
									
										
										
										
											2017-08-22 13:01:33 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | ## Manually enabling accessibility features
 | 
					
						
							| 
									
										
										
										
											2017-08-22 13:01:33 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | Electron applications will automatically enable accessibility features in the | 
					
						
							|  |  |  | presence of assistive technology (e.g. [JAWS](https://www.freedomscientific.com/products/software/jaws/) | 
					
						
							|  |  |  | on Windows or [VoiceOver](https://help.apple.com/voiceover/mac/10.15/) on macOS). | 
					
						
							|  |  |  | See Chrome's [accessibility documentation][a11y-docs] for more details. | 
					
						
							| 
									
										
										
										
											2017-08-24 11:22:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | You can also manually toggle these features either within your Electron application | 
					
						
							|  |  |  | or by setting flags in third-party native software. | 
					
						
							| 
									
										
										
										
											2017-08-24 11:22:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | ### Using Electron's API
 | 
					
						
							| 
									
										
										
										
											2017-08-24 11:22:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | By using the [`app.setAccessibilitySupportEnabled(enabled)`][setAccessibilitySupportEnabled] | 
					
						
							|  |  |  | API, you can manually expose Chrome's accessibility tree to users in the application preferences. | 
					
						
							|  |  |  | Note that the user's system assistive utilities have priority over this setting and | 
					
						
							|  |  |  | will override it. | 
					
						
							| 
									
										
										
										
											2017-08-24 11:22:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | ### Within third-party software
 | 
					
						
							| 
									
										
										
										
											2017-08-24 11:22:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:37:00 -07:00
										 |  |  | #### macOS
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | On macOS, third-party assistive technology can toggle accessibility features inside | 
					
						
							|  |  |  | Electron applications by setting the `AXManualAccessibility` attribute | 
					
						
							| 
									
										
										
										
											2018-02-19 17:36:49 -06:00
										 |  |  | programmatically: | 
					
						
							| 
									
										
										
										
											2017-08-22 13:01:33 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-26 19:41:56 +02:00
										 |  |  | Using Objective-C: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 13:01:33 -03:00
										 |  |  | ```objc | 
					
						
							|  |  |  | CFStringRef kAXManualAccessibility = CFSTR("AXManualAccessibility"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | + (void)enableAccessibility:(BOOL)enable inElectronApplication:(NSRunningApplication *)app | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     AXUIElementRef appRef = AXUIElementCreateApplication(app.processIdentifier); | 
					
						
							|  |  |  |     if (appRef == nil) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:24:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 13:01:33 -03:00
										 |  |  |     CFBooleanRef value = enable ? kCFBooleanTrue : kCFBooleanFalse; | 
					
						
							|  |  |  |     AXUIElementSetAttributeValue(appRef, kAXManualAccessibility, value); | 
					
						
							|  |  |  |     CFRelease(appRef); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-02-19 17:36:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-26 19:41:56 +02:00
										 |  |  | Using Swift: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```swift | 
					
						
							|  |  |  | import Cocoa | 
					
						
							|  |  |  | let name = CommandLine.arguments.count >= 2 ? CommandLine.arguments[1] : "Electron" | 
					
						
							|  |  |  | let pid = NSWorkspace.shared.runningApplications.first(where: {$0.localizedName == name})!.processIdentifier | 
					
						
							|  |  |  | let axApp = AXUIElementCreateApplication(pid) | 
					
						
							|  |  |  | let result = AXUIElementSetAttributeValue(axApp, "AXManualAccessibility" as CFString, true as CFTypeRef) | 
					
						
							|  |  |  | print("Setting 'AXManualAccessibility' \(error.rawValue == 0 ? "succeeded" : "failed")") | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-19 17:36:49 -06:00
										 |  |  | [a11y-docs]: https://www.chromium.org/developers/design-documents/accessibility#TOC-How-Chrome-detects-the-presence-of-Assistive-Technology | 
					
						
							|  |  |  | [setAccessibilitySupportEnabled]: ../api/app.md#appsetaccessibilitysupportenabledenabled-macos-windows |