Programmatically select a cell in NSMatrix automatically makes the cell visible

134 views Asked by At

I've been working with some legacy codes, and the current situation is I have a NSMatrix as a group of radio buttons inside a NSScrollView. The NSMatrix is at the top of the NSScrollView, and the NSScrollView can contain up to hundreds of other subviews.

Every time when the function -(void)selectCellAtRow:(NSInteger)row column:(NSInteger)column is used to programmatically select a radio button in the NSMatrix, the NSScrollView will automatically scroll up so that the selected radio button will be visible. Some customers find it very annoying.

Is it a default behavior of that function? How do I stop this automatic scrolling?

Related, but not the same, question: Selecting Item of NSMatrix programatically

1

There are 1 answers

1
Willeke On BEST ANSWER

selectCellAtRow:column: triggers scrollCellToVisibleAtRow:column:. Subclass NSMatrix, override

- (void)scrollCellToVisibleAtRow:(NSInteger)row column:(NSInteger)col;

and don't call super (if the matrix is invisible).