如何将光标强制到NSTextField的末尾? [英] How do I force the cursor to the end of a NSTextField?

查看:192
本文介绍了如何将光标强制到NSTextField的末尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NSOpenPanel从用户的计算机中选择一个文件或文件夹。但是当用户单击打开时,光标位于文本字段中显示的路径的开头。这是一个问题,因为直到你点击文本字段和箭头右,你不会看到整个路径列出。例如,如果路径是:

  / Users / jeremysmith / code / testfolder / testfolder2 
  

用户/ jeremysmith / code /

,因为光标位于开头,文本字段的宽度仅为code。

解决方案

我在textfields上工作:

  [[self.inputFileTextField currentEditor] moveToEndOfLine:nil]; 


I am NSOpenPanel to select a file or folder from a user's machine. But when the user clicks "open" the cursor is at the beginning of the path that shows up in the text field. This is a problem because until you click in the textfield and arrow right, you won't see that the entire path is listed. For example if the path is:

/Users/jeremysmith/code/testfolder/testfolder2

It may only show:

/Users/jeremysmith/code/

since the cursor is at the beginning and the text field's width only goes to "code".

解决方案

I got this working on textfields by doing:

[[self.inputFileTextField currentEditor] moveToEndOfLine:nil];

这篇关于如何将光标强制到NSTextField的末尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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