简体   繁体   English

NSTextView中的游标

[英]Cursor in NSTextView

I have a scroll view, and a number of custom views (same class) inside it. 我有一个滚动视图,并且其中包含许多自定义视图(相同的类)。 Each custom view contains an NSTextView. 每个自定义视图都包含一个NSTextView。 I want the cursor to stay as arrow all the time, because the text views are not editable. 我希望光标始终保持箭头状态,因为文本视图不可编辑。 However, setting the cursor using attributed string only controls the areas where there are characters. 但是,使用属性字符串设置光标只能控制有字符的区域。 So I tried to override the mouseMoved method of the scroll view. 因此,我尝试覆盖滚动视图的mouseMoved方法。 This does the trick but when I scroll the view by triggering the scrollWheel event, the cursor changed back to IBeam again. 这可以解决问题,但是当我通过触发scrollWheel事件滚动视图时,光标再次变回了IBeam。

Any idea how to solve this problem? 任何想法如何解决这个问题?

Thanks 谢谢

Have you tried just calling 你试过只是打电话

[textView setSelectable:NO];

to force the arrow cursor to be used (assuming the textView is also not editable via -setEditable: )? 强制使用箭头光标(假设-setEditable:也不能通过-setEditable:编辑)?

Otherwise, you might look into the following: Managing Cursor-Update Events . 否则,您可能会研究以下内容: 管理游标更新事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM