开发者

Send action from NSTextField when on key up instead of return

开发者 https://www.devze.com 2023-01-21 06:16 出处:网络
I want to show the number of characters left for a new tweet, after a key has been lifted. Current开发者_C百科ly, this only happens if return is lifted:

I want to show the number of characters left for a new tweet, after a key has been lifted. Current开发者_C百科ly, 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!!):

Send action from NSTextField when on key up instead of return

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消