NSTextView 封闭滚动视图在空格键上跳转

发布于 2024-11-26 02:23:04 字数 144 浏览 2 评论 0原文

我的应用程序有一个奇怪的行为,我不知道它来自哪里。我已经为文本视图内容实现了 NSScanner,效果非常好。扫描器与文本存储结合使用,通过文本视图委托方法设置文本存储字符串的属性。但是,每次我输入空格时,封闭的滚动视图都会滚动回文本视图的顶部。谁能给我提示这是从哪里来的?

I have an odd behavior with my app and I don't know where it comes from. I have implemented a NSScanner for a text view content that works very well. The scanner works in conjunction with the text storage to set attributes on the text storage string via text view delegate methods. However, each time I enter a space, the enclosing scroll view scrolls back to the top of the text view. Can anyone give me a hint where this comes from ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别挽留 2024-12-03 02:23:04

对于那些比我更有经验的人来说可能没有太多麻烦,我发现了这种行为的可能原因(见上文),所以我将其发布在这里,以防有人会寻找类似“问题”的解决方案。似乎在 NSTextView 的 XCode 4.x 属性检查器中关闭“非连续布局”选项可以解决问题。 NSLayoutManager 的文档提供了更多线索(在“概述”部分下):“非连续布局是 Mac OS X v10.5 中新增的可选布局管理器行为...”

也许比我更有经验的人会提供更多关于此和当选中非连续选项(默认情况下)时,封闭滚动条视图出现此行为的原因。

Probably not much hassle for those more experienced than me, I found out the possible reason for this behavior (see above) so I post it here in case anyone will look for solutions for similar "problems". It seems that turning off "Non-contiguous layout" option in the XCode 4.x attributes inspector for the NSTextView in case will solve the problem. The documentation for NSLayoutManager provides more clues (under "Overview" section): "Noncontiguous layout is an optional layout manager behavior new in Mac OS X v10.5..."

Maybe somebody more experienced than me will provide more info on this and the reason of this behavior of the enclosing scroller view when non-contiguous option is checked (which is, by default).

凉世弥音 2024-12-03 02:23:04

我遇到了同样的问题,关闭“非连续布局”确实解决了问题,但它引起了另一个问题,即 NSTextView 对于 10k 行文本变得缓慢。 ​​类似的问题已得到不同的回答,但我想知道如果有效的话。该解决方案还施加了一些限制,但可能不适用于您。

I am stuck with the same problem and turning off "Non-contiguous layout" does solve the problem, but it gives rise to another problem which is that the NSTextView gets sluggish for 10k lines of text. A similar question has been answered differently but I wonder if it works. That solution also imposes some restrictions which may not be applicable to you though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文