Send action from NSTextField when on key up instead of return

倖福魔咒の 提交于 2019-12-10 19:49:50

问题


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.


回答1:


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

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



来源:https://stackoverflow.com/questions/4003815/send-action-from-nstextfield-when-on-key-up-instead-of-return

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