如何检测NSOutlineView的滚动? [英] How to detect scrolling for NSOutlineView?

查看:222
本文介绍了如何检测NSOutlineView的滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个并列显示的NSOutlineView,它们包含相同数量的行(这是一个先决条件),我需要在用户使用鼠标,键盘或滚动条滚动时同步它们,所以我看到相同的视图部分)。



我是可可土地上的新手,我无法找到这是如何完成的

 <$ c> 

$ c> NSClipView * clipView = [[outlineView enclosedingScrollView] contentView];

...并将其-setPostsFrameChangedNotifications设置为YES。从该视图中侦听NSViewFrameDidChangeNotification并相应地做出响应。



注意:命名法不太清楚。大多数人对-contentView的第一个期望是:它返回正在滚动的视图。 -contentView:方法返回滚动视图的NSClipView,而-documentView:方法返回正在滚动的实际视图。


I've two NSOutlineViews shown side by side they contain the same number of rows (this is a prerequisite) and I need to synchronize them when user scrolls using mouse, keyboard or scrollbars so I see the same view portion (or rows).

I'm a newbie in the Cocoa land and I'm unable to find how this can be accomplished

解决方案

You'll want to get the clip view of the NSOutlineView's enclosing scroll view:

NSClipView * clipView = [[outlineView enclosingScrollView] contentView];

...and set its -setPostsFrameChangedNotifications: to YES. Listen for the NSViewFrameDidChangeNotification from that view and respond accordingly.

Note: The nomenclature isn't very clear. Most people's first expectation of -contentView: is that it returns the view being scrolled. The -contentView: method returns the scroll view's NSClipView whereas the -documentView: method returns the actual view being scrolled.

这篇关于如何检测NSOutlineView的滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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