Øystein
Øystein

Reputation: 1223

Change language for spell check in NSTextField runtime

I am working on an application that lets the user install a new language to his OS X spelling. In this application I also want the user to be able to test the new language added by entering some text into a NSTextField.

The user changes the spelling language through the system preferences app, as normal. My problem is that the NSTextField component does not change the spelling language it is using when the user changes it in the preferences app. I have to quit my application and relaunch it for it to change spelling language.

I have tried releasing the NSTextField, and allocating it again after the language change is done, but that makes no difference.

So I hope that someone could point me to how I refresh the language used for spell check within NSTextField runtime?

Upvotes: 3

Views: 325

Answers (1)

A.Steinel
A.Steinel

Reputation: 186

You can use the following code:

NSSpellChecker *sc = [NSSpellChecker sharedSpellChecker];
[sc setAutomaticallyIdentifiesLanguages:false];
[sc setLanguage:@"en"];

Upvotes: 1

Related Questions