Instance Method

setSelectionFrom:to:anchor:highlight:

Programmatically selects a range of cells.

Declaration

- (void)setSelectionFrom:(NSInteger)startPos to:(NSInteger)endPos anchor:(NSInteger)anchorPos highlight:(BOOL)lit;

Parameters

startPos

The position of the cell that marks where the user would have pressed the mouse button.

endPos

The position of the cell that marks where the user would have released the mouse button.

anchorPos

The position of the cell to treat as the last cell the user would have selected. To simulate Shift-dragging (continuous selection) anchorPos should be the endPos used in the last method call. To simulate Command-dragging (discontinuous selection), anchorPos should be the same as this method call’s startPos.

lit

YES if cells selected by this method should be highlighted.

Discussion

startPos, endPos, and anchorPos are cell positions, counting from 0 at the upper left cell of the receiver, in row order. For example, the third cell in the top row would be number 2.

To simulate dragging without a modifier key, deselecting anything that was selected before, call deselectAllCells before calling this method.

See Also

Selecting and Deselecting Cells

- selectCellAtRow:column:

Selects the cell at the specified row and column within the receiver.

- selectCellWithTag:

Selects the last cell with the given tag.

- selectAll:

Selects and highlights all cells in the receiver.

keyCell

The cell that will be clicked when the user presses the Space bar.

- deselectAllCells

Deselects all cells in the receiver and, if necessary, redisplays the receiver.

- deselectSelectedCell

Deselects the selected cell or cells.