更改 NSTextField 运行时中拼写检查的语言

发布于 2024-12-15 11:39:54 字数 303 浏览 4 评论 0原文

我正在开发一个应用程序,让用户可以为其 OS X 拼写安装一种新语言。在此应用程序中,我还希望用户能够通过在 NSTextField 中输入一些文本来测试添加的新语言。

用户照常通过系统首选项应用程序更改拼写语言。我的问题是,当用户在首选项应用程序中更改 NSTextField 组件时,它不会更改它正在使用的拼写语言。我必须退出我的应用程序并重新启动它才能更改拼写语言。

我尝试释放 NSTextField,并在语言更改完成后再次分配它,但这没有什么区别。

所以我希望有人能指出我如何刷新 NSTextField 运行时中用于拼写检查的语言?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如痴如狂 2024-12-22 11:39:54

您可以使用以下代码:

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

You can use the following code:

NSSpellChecker *sc = [NSSpellChecker sharedSpellChecker];
[sc setAutomaticallyIdentifiesLanguages:false];
[sc setLanguage:@"en"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文