views:

165

answers:

1

Hi,

I'm not asking how to do this, it's more in line of "What would you call this?".

I have an NSTableView with several custom cells. I want the table to scroll row by row, meaning that when I move the scrollbar up I want the top row to disappear and when I move it down I want the bottom row also to disappear - I don't want to see half my cell.

How do you call this type of behavior? And can you share some pointers if you've implemented it in a NSTableView?

+1  A: 

I'm not exactly sure what this would be called (maybe something like "constrained scrolling"?), but you can do it using NSView's -adjustScroll: method.

The general approach is that you need to make a subclass of NSTableView (if you don't already have one), and override this method to return a NSRect that has its origin.y value constrained to a multiple of your row height.

You probably also want to use NSScrollView's -setVerticalLineScroll: to set the proper amount to scroll when the user clicks the scroll arrows in the vertical scroll bar. You can get the scrollView by calling -enclosingScrollView on your tableView.

Kelan
Thanks for the tip. Let me test a bit before I accept the answer.
Rui Pacheco