]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Make "Text to Speech" work, fixes atom/atom#3288.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 17 Aug 2014 03:26:02 +0000 (11:26 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 17 Aug 2014 03:30:26 +0000 (11:30 +0800)
atom/browser/native_window_mac.mm

index 885eb3b0f7d4a1bbfe3366ae1bb8b1f533eae8c7..6f59187ce5fd2fe04bb0a8dfdcc9548f18f8d483 100644 (file)
@@ -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 {