Objective-C,自动擦除NSTextField字符串 [英] Objective-C, auto erase NSTextField string

查看:235
本文介绍了Objective-C,自动擦除NSTextField字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出如何自动擦除NSTextField中的字符串,点击它内部。

I've been trying to figure out how to auto erase a string within an NSTextField upon clicking within in it.

例如,当前的行为在OSX上是这样的:

For example the current behavior is like this on OSX:


当用户单击单元格或默认焦点是单元格时,该单词有时会突出显示或光标放在文本的中间。然后,用户需要使用退格删除文本(我想通过自动删除文本消除)。

When a user clicks in the cell or the default focus is the cell either the word is sometimes highlighted or the cursor is placed in the middle of the text. The user then needs to use backspace to delete the text (which I'd like to eliminate by automatically removing the text).

这是一个内置的函数,我不知何故丢失了?

Is this a function that is built-in that I'm somehow missing? If not how would I go about it?

推荐答案

有很多可怕的想法盒外,这是一个

There are plenty of terrible ideas "outside the box", and this is one of them.

无论如何,创建 NSTextField 的子类。覆盖 becomeFirstResponder 。如果 [super becomeFirstResponder] 返回 YES ,请设置 self.stringValue = @ code>。

Anyway, make a subclass of NSTextField. Override becomeFirstResponder. If [super becomeFirstResponder] returns YES, set self.stringValue = @"".

这篇关于Objective-C,自动擦除NSTextField字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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