Platforms to show: All Mac Windows Linux Cross-Platform
/MacCocoa/NSSpeechSynthesizer Progress
Function:
Required plugins for this example: MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSSpeechSynthesizer Progress
Function:
Required plugins for this example: MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSSpeechSynthesizer Progress
Project "NSSpeechSynthesizer Progress.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control StartButton Inherits PushButton
ControlInstance StartButton Inherits PushButton
EventHandler Sub Action()
if s.startSpeakingString(EditField1.text) then
StopButton.Enabled=True
StartButton.Enabled=False
end if
End EventHandler
End Control
Control StopButton Inherits PushButton
ControlInstance StopButton Inherits PushButton
EventHandler Sub Action()
s.StopSpeaking
StopButton.Enabled=False
StartButton.Enabled=true
End EventHandler
End Control
EventHandler Function KeyDown(Key As String) As Boolean
if asc(key)=27 then
if s.IsSpeaking then
s.StopSpeaking
end if
Return true
end if
End EventHandler
EventHandler Sub Open()
s=new MyNSSpeechSynthesizerMBS
End EventHandler
Property Protected s As MyNSSpeechSynthesizerMBS
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open()
if TargetMachO=false then
MsgBox "This example needs a MachO target running on Mac OS X."
quit
end if
End EventHandler
End Class
Class MyNSSpeechSynthesizerMBS Inherits NSSpeechSynthesizerMBS
EventHandler Sub didFinishSpeaking(finishedSpeaking as boolean)
if finishedSpeaking then
MainWindow.StartButton.Enabled=true
MainWindow.StopButton.Enabled=False
end if
End EventHandler
EventHandler Sub willSpeakWord(Position as integer, Length as integer, Text as String)
if Position<0 then Return
MainWindow.EditField1.SelStart=Position
MainWindow.EditField1.SelLength=Length
End EventHandler
Property LastText As string
End Class
End Project
The items on this page are in the following plugins: MBS MacCocoa Plugin.