From: Satoshi N. <sna...@in...> - 2008-02-15 05:13:15
|
Hi, The delegate method of NSSpeechSynthesizer is "speechSynthesizer:didFinishSpeaking:". So try this: def speechSynthesizer_didFinishSpeaking(sender, success) NSLog(@"Finished speaking"); end -- Satoshi Nakagawa On 2008/02/15, at 12:07, Justin Stone wrote: > I'm trying to port a simple objective-c application (from a book on > cocoa in os x) to Ruby in Xcode. Basically the application takes a > line of text and then says the line (out loud). This all works fine > but I'm having trouble figuring out how to do the delegate to make the > stop button disable itself when the app finishes saying the line. > Here's the code: > > require 'osx/cocoa' > include OSX > > class Speak < NSObject > ib_outlets :textField, :stopButton > > def initialize > @speechSynth = NSSpeechSynthesizer.alloc().initWithVoice_(nil) > @speechSynth.setDelegate_(self) > end > > ib_action :say do |sender| > blah = @textField.stringValue() > > if blah.empty? > return > end > > @stopButton.setEnabled_(true) > if (rand(10)+1) == 1 > @speechSynth.startSpeakingString_("I'm not going to say that") > else > @speechSynth.startSpeakingString_(blah) > end > > NSLog("Have started to say: #{blah}\n") > end > > ib_action :stop do |sender| > NSLog("Stopping.") > @speechSynth.stopSpeaking > end > > def didFinishSpeaking(sender) > NSLog("Finished Speaking.") > @stopButton.setDisabled_(true) > end > end > > > It compiles and runs fine. The only thing that doesn't work is > didFinishSpeaking is not called by @speechSynth when it finishes > speaking. Any ideas on what I'm doing wrong? > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |