如何找到重点关注的 NSTextfield
我在查找重点关注的 NSTextfield
时遇到问题。
我正在构建一个多语言表单,并有几个用于数据输入的 NSTextfield 。我必须在数据输入期间更改某些 NSTextfields
的文本输入源,并且我需要它自动发生。
现在,我可以按照我在此处提到的方式更改文本输入源,没有问题。
我遇到的问题是当 NSTextfield 获得焦点时立即更改输入源。如果我使用 controlTextDidBeginEditing:
委托方法,它会在键入第一个字母后更改源输入。 这意味着我丢失了用正确语言输入的第一个单词。
有没有代表去找找?
I'm having a problem finding out which NSTextfield
is focused.
I am building a multi-language form and have several NSTextfield
s for data entry. I have to change the text input source for some of the NSTextfields
during data entry, and I need it to happen automatically.
For now, I can change the text input source as I mentioned here without problem.
The problem that I have is to change the input source right when the NSTextfield
becomes focused. If I use the controlTextDidBeginEditing:
delegate method it changes the source input after typing the first letter.
This means that I lose the first word I typed in proper language.
Is there any delegate to find it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以子类化 NSTextField 并覆盖
- (BOOL)becomeFirstResponder
(NSResponder
) 来响应此类事件。您也可以尝试使用
control:textShouldBeginEditing:
来代替。You can subclass your NSTextField and override
- (BOOL)becomeFirstResponder
(NSResponder
) to respond to this kind of event.You can also try
control:textShouldBeginEditing:
instead.您需要
NSTextField
Swift 3+在视图控制器内对
self.view.window?.firstResponder
进行子类化,以提供NSTextView< /代码>
You will need to subclass
NSTextField
Swift 3+
self.view.window?.firstResponder
inside your view controller would give aNSTextView