NSTextField GotFocus Event Cocoa Swift

做~自己de王妃 提交于 2019-12-25 09:47:38

问题


In swift Cocoa is there an event that fires when a NSTextField gets focus for editing. I Come from C# which has GotFocus() and LostFocus() Events.

For NSTextfield I could find only these functions which fire after one starts typing. Not as soon as focus is gained.

 override func controlTextDidBeginEditing(obj: NSNotification) {
 }

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

 }

I Need this because as soon as someone starts editing, I want to show more detail. I have a simpler display name, and full name for editing.

Thanks,


回答1:


You can subclass NSTextField and override becomeFirstResponder and resignFirstResponder. Please check this link How to detect when NSTextField has the focus or is it's content selected cocoa



来源:https://stackoverflow.com/questions/28807742/nstextfield-gotfocus-event-cocoa-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!