Q:  How do I programmatically make a multiple selection in a matrix?  I want it to behave exactly as though the user had shift-clicked to select several cells.

A:  You must call setState: and highlight:inView:lit: for each cell that you want to select.  Here is a code fragment which will select all the even-numbered cells and deselect all the odd-numbered cells in a matrix.

    int rows;
    
    [matrix getNumRows:&rows numCols:NULL];
    [matrix lockFocus];
    while (rows--) {
	NXRect rect;
    	BOOL even = (((rows % 2) == 0) ? 1 : 0);
    	id cell = [matrix cellAt:rows:0];
	[matrix getCellFrame:&rect at:rows :0];
	[cell setState:even];
	[cell highlight:&rect inView:matrix lit:even];
    }
    [matrix unlockFocus];
    [[matrix window] flushWindow];

QA853

Valid for 1.0, 2.0, 3.0