How to detect scrolling for NSOutlineView?

那年仲夏 提交于 2019-12-11 04:47:13

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/5363728/get-scroll-bar-position-of-an-nsscroller-on-the-fly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!