Acessibilidade
As questões de acessibilidade em aplicativos Electron são semelhantes às de sites na Web, já que ambos fazem uso do HTML.
Habilitando manualmente os recursos de acessibilidade
Aplicativos Electron ativarão automaticamente recursos de acessibilidade na presença de tecnologia assistiva (por exemplo, JAWS no Windows ou VoiceOver no macOS). Confira a documentação de acessibilidade do Chrome para mais detalhes.
Você também pode alterar manualmente esses recursos em seu aplicativo Electron ou definindo bandeiras em softwares nativos de terceiros.
Using Electron's API
By using the app.setAccessibilitySupportEnabled(enabled)
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.
Within third-party software
macOS
On macOS, third-party assistive technology can toggle accessibility features inside Electron applications by setting the AXManualAccessibility
attribute programmatically:
Using Objective-C:
CFStringRef kAXManualAccessibility = CFSTR("AXManualAccessibility");
+ (void)enableAccessibility:(BOOL)enable inElectronApplication:(NSRunningApplication *)app
{
AXUIElementRef appRef = AXUIElementCreateApplication(app.processIdentifier);
if (appRef == nil)
return;
CFBooleanRef value = enable ? kCFBooleanTrue : kCFBooleanFalse;
AXUIElementSetAttributeValue(appRef, kAXManualAccessibility, value);
CFRelease(appRef);
}
Using 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")")