单击编辑 NSTextField
我很抱歉再次问这个问题,我已经查看了这里所有相关的问题,但似乎没有一个对我有帮助(或者我只是无法理解)。
Atm,我有一个 NSTextField
,其操作方式与同类产品类似,但它需要双击到三次才能选择其所有内容进行编辑(双击选择一个单词,三次选择所有内容) )。
不幸的是,我需要它以某种方式工作,当用户单击它一次时,所有文本都会被选中,这样人们就可以立即开始输入新内容。
I'm sorry to ask this again, I've looked over all the related questions here, but none seems to help me (or I just can't get it).
Atm, I have an NSTextField
that operates like every other of its kind, but it needs double-to-triple click to select all of it's content for editing (double selects one word, triple - all of them).
I unfortunately need this to work in a way, that when a user clicks on it once, all the text gets selected, so one can start typing a new thing instantly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您应该遵循此 重复问题
,一旦您进入自己的派生
-(void) mouseDown: (NSEvent *) theEvent
方法,只需通过调用[NSTextField selectText:]
或
[NSText setSelectedRange:]
Basically you should follow the solutions in this duplicate question
and once you are in your own derived
-(void) mouseDown: (NSEvent *) theEvent
method, simply select all the text by doing calls to either[NSTextField selectText:]
or
[NSText setSelectedRange:]