--- a/PDFViewer/Base.lproj/Main.storyboard
+++ b/PDFViewer/Base.lproj/Main.storyboard
@@ -323,22 +323,9 @@
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask"/>
- <menu key="submenu" title="Speech" id="3rS-ZA-NoH">
- <items>
- <menuItem title="Start Speaking" id="Ynk-f8-cLZ">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="startSpeaking:" target="Ady-hI-5gd" id="654-Ng-kyl"/>
- </connections>
- </menuItem>
- <menuItem title="Stop Speaking" id="Oyz-dy-DGm">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="stopSpeaking:" target="Ady-hI-5gd" id="dX8-6p-jy9"/>
- </connections>
- </menuItem>
- </items>
- </menu>
+ <connections>
+ <action selector="startSpeaking:" target="Ady-hI-5gd" id="935-lp-dLm"/>
+ </connections>
</menuItem>
</items>
</menu>
@@ -669,7 +656,7 @@
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="75" y="250"/>
+ <point key="canvasLocation" x="-87" y="59"/>
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
@@ -696,7 +683,7 @@
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="115" y="1014"/>
+ <point key="canvasLocation" x="-87" y="906"/>
</scene>
</scenes>
</document>
--- a/PDFViewer/pdfviewer/PDFViewer.h
+++ b/PDFViewer/pdfviewer/PDFViewer.h
@@ -11,7 +11,13 @@
NSSpeechSynthesizer *synthesizer;
}
+/* Action-Override für First-Responder */
+- (IBAction)startSpeaking:(id)sender;
+- (IBAction)stopSpeaking:(id)sender;
+
+/* Die Methoden der Klasse */
- (NSMutableString *)getTexts;
- (void)speak:(NSMutableString *)texts;
-- (void)stopSpeaking;
+- (void)silence;
+
@end
--- a/PDFViewer/pdfviewer/PDFViewer.m
+++ b/PDFViewer/pdfviewer/PDFViewer.m
@@ -11,7 +11,8 @@
@implementation PDFViewer
- (void)awakeFromNib {
- synthesizer = [[NSSpeechSynthesizer alloc] initWithVoice:[NSSpeechSynthesizer defaultVoice]];
+ synthesizer = [[NSSpeechSynthesizer alloc]
+ initWithVoice:[NSSpeechSynthesizer defaultVoice]];
}
- (NSMutableString *)getTexts {
@@ -28,15 +29,31 @@
return strings;
}
+/* Button Action startSpeaking */
+- (IBAction)startSpeaking:(id)sender {
+ if (!synthesizer.isSpeaking) {
+ NSMutableString *string = [self getTexts];
+ [self speak:string];
+ } else {
+ [self silence];
+ }
+}
+
+/* Button Action stopSpeaking */
+- (IBAction)stopSpeaking:(id)sender {
+ [self silence];
+}
+
+/* Sprachausgabe an */
- (void)speak:(NSMutableString *)texts {
- // Die Audioausgabe muss immer gestoppt werden, bevor Sie erneut gestartet
- // werden darf!
- [self stopSpeaking];
+ // Die Audioausgabe muss immer gestoppt werden, bevor Sie erneut gestartet werden darf!
+ [self stopSpeaking:self];
[synthesizer startSpeakingString:texts];
}
-- (void)stopSpeaking {
+/* Sprachausgabe aus */
+- (void)silence {
if ([synthesizer isSpeaking]) {
[synthesizer stopSpeaking];
}
--- a/PDFViewer/viewcontroller/ViewController.m
+++ b/PDFViewer/viewcontroller/ViewController.m
@@ -28,7 +28,7 @@
}
- (void)viewDidDisappear {
- [_pdfViewer stopSpeaking];
+ [_pdfViewer stopSpeaking:self];
}
- (void)setRepresentedObject:(id)representedObject {