NSTextField GotFocus事件Cocoa Swift [英] NSTextField GotFocus Event Cocoa Swift

查看:826
本文介绍了NSTextField GotFocus事件Cocoa Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在swift Cocoa有一个事件,当NSTextField获得焦点编辑时触发。我来自C#它有GotFocus()和LostFocus()事件。

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.

对于NSTextfield我可以找到只有这些功能,一旦开始打字。

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.

感谢,

推荐答案

您可以继承NSTextField并覆盖becomeFirstResponder和resignFirstResponder。请检查此链接如何检测NSTextField何时具有焦点或是否是可选内容

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

这篇关于NSTextField GotFocus事件Cocoa Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆