2015-03-02 80 views
0

在swift中Cocoa有一个事件在NSTextField获得焦点进行编辑时触发。我来自具有GotFocus()和LostFocus()事件的C#。NSTextField GotFocus事件Cocoa Swift

对于NSTextfield,我只能找到这些在开始输入后触发的函数。并不是一旦获得重点。

override func controlTextDidBeginEditing(obj: NSNotification) { 
} 

func control(control: NSControl, textShouldBeginEditing fieldEditor: NSText) -> Bool { 

} 

我需要这个,因为只要有人开始编辑,我想显示更多的细节。我有一个更简单的显示名称和全名进行编辑。

感谢,

回答

2

你也可以继承的NSTextField和覆盖becomeFirstResponder和resignFirstResponder。请检查此链接How to detect when NSTextField has the focus or is it's content selected cocoa

+0

请检查Ur拼写NSTextfield“UITextfield” – 2015-03-02 11:11:22

+2

@Abhay,NSTextField在UIKit的Cocoa和UITextField中。这不是一个拼写错误 – 2015-03-02 11:18:40

+0

哦....抱歉花花公子 – 2015-03-02 11:36:29