I am developing a multi-language OSX app which also uses text-to-speech.
I am using mac's VoiceOver and Applescript to control it.
In the app, users can switch languages and VoiceOver has to read the text in the selected language.
The goal is to switch VoiceOver language without quitting my application.
I can't find a way in Cocoa or Applescript to find out what is the current language in VoiceOver and to actively specify what language to set.
This is what I have done so far.
In VoiceOver Utility there is a section called Activities that lets you setup some VoiceOver configurations, including the language.
So I created an English and a French activity.
Then I found this really helpful list of commands that you can use in Applescript to control VoiceOver: http://www.cbtbc.org/tools/asvo/voec.php
In this list the only commands that control VoiceOver activities are: "open activity chooser"
and "previous activity"
"previous activity" changes the language, but there's no way to know what activity you are currently on or to specify the name of the activity that you want to go to (English or French) when the user presses the language button.
So for example, if the user clicks on the English button twice, or switches the app language when the VoiceOver is off, the application might be showing English text while the VoiceOver might be set in French.
Anybody had experience with this?
Thank you so much for your help!
Related
I understand that the language of Message Box buttons is linked to the language of the Windows system. But this may not be the language of the end user. For instance, in a county like Switzerland having four official languages (German, French, Italian and Romansh), it is not unusual for a Windows system to be set up in English and not fit the user's needs. Adjusting the Windows Regional and Language options does not affect the language of Message Box buttons.
Is there any way to dynamically set an application to respect the System.Globalization.CultureInfo.CurrentCulture.LCID instead of the system language? I tried playing around with the parent form Localizable and Language settings with no success.
Any insight would be appreciated. Thanks!
When using location services, I get this message: ““YourApp” Would Like to Use Your Current Location”
Is there any way to change this to another language, even if the iOS language is set to English? (My app comes in one non-English language only, so it’s weird to have that English dialog pop up in my non-English app.)
If you are using CLLocationManager, you can set its purpose property to any text you like.
This text will be displayed in addition to and under the standard "AppName Would Like To Use Your Current Location" text.
I would be very surprised if you can do that!
This is a matter of user privacy and it should be stated in the language selected by the user not you (developer).
On stock OS iOS devices, the language of OS privacy warnings is under user control, not an app's control via any public API.
Is there a way to programmatically turn on and off the Bluetooth connection on OSX in a way that will be accepted by the Mac App Store?
From my previous question, I've found about blueutil, but it uses private APIs.
It would be somewhat surprising if Apple approved an app that modified the user's antenna settings. It sounds like the kind of thing they typically frown on, no matter how you do it. But then, sometimes I get surprised.
You can definitely do it through Applescript:
tell application "System Preferences"
set current pane to pane "com.apple.preferences.Bluetooth"
tell application "System Events"
tell process "System Preferences"
set isOnCheckbox to checkbox "On" of window "Bluetooth"
if value of isOnCheckbox is 0 then
click isOnCheckbox
end if
end tell
end tell
quit
end tell
Note that this will take over System Preferences and at the end close it even if the user was running it. That's not the best user experience, and I definitely wouldn't do it without first warning the user. But of course, I wouldn't recommend modifying the bluetooth settings without warning the user.
EDIT
Because you asked, I'll take a moment to rant here....
Regarding how to learn to read and write the above, first note that it, like most AppleScript I write professionally, was cobbled together from google searches and experimentation. I'm a purist programmer at heart, and I believe in really understanding the technology you use. Even I cobble together things in AppleScript until they "kind of work."
I wish there were a really good document. Of course there's the language guide, but it's kind of like learning Cocoa from the ObjC language definition. My current recommendations are Beginning AppleScript and then AppleScript: The Definitive Guide. Neuburg in particular does not sugarcoat the language or pretend that it makes sense. Applescript, even worse than the original COBOL (ADD X TO Y GIVING Z), is very hard to write because it tries so hard to be easy. I love and respect many languages. AppleScript is crap.
It is, however, the most supported way to interact with most of the Mac system functions, so a good Mac developer needs to at least be able to get by in it. Even if you use the new ScriptingBridge via ObjC (or MacRuby), the underlying object model is still AppleScript based. In my experience, to get ScriptingBridge code to work well, you generally have to write it first in AppleScript and then translate it into Cocoa.
This worked for me in 10.15.6, I might have over complicated my solution which is running script 1 (turn bluetooth off) and then script 2 (turn bluetooth on).
Script 1. This is for turning bluetooth OFF
tell application "System Events" to tell process "SystemUIServer"
tell (menu bar item 1 of menu bar 1 where description is "bluetooth")
click
click menu item "Turn Bluetooth Off" of menu 1
end tell
tell window 1
click button "Turn Bluetooth Off"
end tell
end tell
Script 2. This is for turning bluetooth ON
tell application "System Events" to tell process "SystemUIServer"
tell (menu bar item 1 of menu bar 1 where description is "bluetooth")
click
click menu item "Turn Bluetooth On" of menu 1
end tell
end tell
So I execute one command which will run one script after the other, the sleep is for the UI to update properly.
osascript bluetooth_off.scpt && sleep 3s && osascript bluetooth_on.scpt
You can just save the command in a file and execute it using: (they have to be in the same directory).
~ bash <fileName>
Note: You will need to give access to the terminal on Preferences > Security & Privacy
I am developing an application for Mac OS , i need to display a information popup in Mac, In Windows OS context, it should be similar to the one, which used to be displayed near by tray-icon,
More real example is, assuming any messenger application is running, and someone form your contact list became online/available,then Messenger App display a Animated Popup near by tray-icon area,
the same use-case i am having ,
While googling i came to know, either i can make use of NSAlert or Growl , any other application that i should think.
There is no default alternatives to the Windows popup message on the Mac, but the de facto standard for doing this is through Growl. NSAlert popup messages are usually used to display exactly those: alerts. They are often to large and cumbersome to display small amounts of information well without distracting or interrupting the user. Growl, on the other hand, works well for things like these, and is what you should use.
I am a newbie in Mac application development. I want to write a GUI application in Cocoa using Interface Builder. I want multiple screens i.e. when one button on a screen is clicked, another screen should be displayed. How can I activate a new screen at button click event?
I would heartily recommend Aaron Hilegass's book Cocoa Programming for Mac OS X. It took me from feeling like everything was impossible to being relatively competent in the space of a few short weeks. I was very impressed with it.
Apple's documentation is amazingly good, but it takes a while to get used to the style, and you will need to know which objects actually exist before you can look up how to use them, which is where Aaron's book comes in.
Your library may have a copy of it, or be able to order one for you if they don't.
I think you mean windows, not screens. Screens are the displays (monitors) on which all the user's windows from all the user's applications appear.
And I second Jonathan's recommendation of the Hillegass book.
The button has a target. That should link to the new window. As its action you can tell the window to show itself.
Take a look at:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/WinPanel/WinPanel.html
I think what you want is the type of interface like that seen in Coda, or System Preferences where there is a toolbar on the top of the screen that can be used to select between the content of the window.
The simplest method I have found is to use BWToolkit.
Another method is to use a series of views, and switch between them when the toolbar is clicked. I've found one description here, but that's not the one I used first (which may have been originally in Ruby Cocoa, IIRC).
NSTabView.