在键向上而不是返回时,从NSTextField发送操作 [英] Send action from NSTextField when on key up instead of return

查看:133
本文介绍了在键向上而不是返回时,从NSTextField发送操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个键已被解除后剩下的一个新推文的字符数。目前,只有当返回被解除时才会发生:

   - (IBAction)updateCharacterCountFromNewTweetField:(id)sender {
[ newTweetCharacterCount setIntValue:140 - [[sender stringValue] length]];
}

此操作连接到 NSTextField A UITextField!):



这对用户来说是可怕的,因为他们想立即看到字符数,而不只是按回车后。



任何人都可以帮助我吗?感谢。

解决方案

在文本字段上设置一个委托,并实现 controlTextDidChange:委托方法。 / p>

另请参阅文本编辑编程指南:代表消息和通知


I want to show the number of characters left for a new tweet, after a key has been lifted. Currently, this only happens if return is lifted:

- (IBAction)updateCharacterCountFromNewTweetField:(id)sender {
  [newTweetCharacterCount setIntValue:140 - [[sender stringValue] length]];
}

This action is connected to an NSTextField (NOT A UITextField!!):

This is terrible for users, because they want to see the character count immediately, not just after pressing return.

Can anyone help me out? Thanks.

解决方案

Set a delegate on the textfield and have it implement the controlTextDidChange: delegate method.

See also Text Editing Programming Guide: Delegate Messages and Notifications.

这篇关于在键向上而不是返回时,从NSTextField发送操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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