简体   繁体   中英

NSTextField GotFocus Event Cocoa Swift

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,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM