# HG changeset patch # User Markus Bröker # Date 1490736363 -7200 # Node ID fd23014eaa851498e4c945c7b5bcf3f26f94e365 # Parent 58bbaa38119ee0e396ed41c5c6a2e4e4b6f9ae38 Abgleichen des Menüpunkts "Speech" mit der Anwendungslogik diff --git a/PDFViewer/Base.lproj/Main.storyboard b/PDFViewer/Base.lproj/Main.storyboard --- a/PDFViewer/Base.lproj/Main.storyboard +++ b/PDFViewer/Base.lproj/Main.storyboard @@ -323,22 +323,9 @@ - - - - - - - - - - - - - - - - + + + @@ -669,7 +656,7 @@ - + @@ -696,7 +683,7 @@ - + diff --git a/PDFViewer/pdfviewer/PDFViewer.h b/PDFViewer/pdfviewer/PDFViewer.h --- 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 diff --git a/PDFViewer/pdfviewer/PDFViewer.m b/PDFViewer/pdfviewer/PDFViewer.m --- 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]; } diff --git a/PDFViewer/viewcontroller/ViewController.m b/PDFViewer/viewcontroller/ViewController.m --- 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 {