How to detect scrolling for NSOutlineView?

后端 未结 1 596
梦如初夏
梦如初夏 2021-01-21 12:29

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

相关标签:
1条回答
  • 2021-01-21 12:44

    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.

    0 讨论(0)
提交回复
热议问题