From: Cheng Zhao Date: Sun, 17 Aug 2014 03:26:02 +0000 (+0800) Subject: mac: Make "Text to Speech" work, fixes atom/atom#3288. X-Git-Tag: v0.15.8~7 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=73bb05e5305dbef56417dcf1508c1408692242ba;p=electron.git mac: Make "Text to Speech" work, fixes atom/atom#3288. --- diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 885eb3b0..6f59187c 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -133,6 +133,20 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; shell_->OpenDevTools(); } +// Returns an empty array for AXChildren attribute, this will force the +// SpeechSynthesisServer to use its classical way of speaking the selected text: +// by invoking the "Command+C" for current application and then speak out +// what's in the clipboard. Otherwise the "Text to Speech" would always speak +// out window's title. +// This behavior is taken by both FireFox and Chrome, see also FireFox's bug on +// more of how SpeechSynthesisServer chose which text to read: +// https://bugzilla.mozilla.org/show_bug.cgi?id=674612 +- (id)accessibilityAttributeValue:(NSString*)attribute { + if ([attribute isEqualToString:@"AXChildren"]) + return [NSArray array]; + return [super accessibilityAttributeValue:attribute]; +} + @end @interface ControlRegionView : NSView {