About Matrices
NSMatrix
is a class used for creating groups of NSCell
objects (or simply, cells or cell objects) that work together in various ways. It includes methods for arranging cells in rows and columns, either with or without space between them. Cell objects in an NSMatrix are numbered by row and column, each starting with 0; for example, the top left cell would be at (0, 0), and the cell that’s second down and third across would be at (1, 2).
The cell objects that an NSMatrix
contains are usually of a single subclass of NSCell
, but they can be of multiple subclasses of NSCell
. The only restriction is that all cell objects must be the same size. An NSMatrix
object can be set up to create new cell objects by copying a prototype object, or by allocating and initializing instances of a specific NSCell
class. Cells created by or added to an NSMatrix
are retained by the matrix.
An NSMatrix
object (or, simply, matrix) adds to the target-action paradigm implemented by cell objects (specifically, cells that inherit from NSActionCell
) by maintaining its own target and action in addition to the targets and actions of its cell objects. A matrix's target and action are used if one of its cells doesn't have a target or action set. This design allows for common usage patterns, including the following:
If none of the cells of the
NSMatrix
object has either target or action set, the target and action of theNSMatrix
object is always used.If only the actions of each of the cells is set, they share the target specified by their
NSMatrix
object, but send different messages to it.If only the targets of each of the cells is set, they all send the action message specified by the
NSMatrix
object, but to different targets.
When the user double-clicks an NSMatrix
object, it can dispatch a separate action message (the selector for which is set via setDoubleAction:
); this double-click action message is in addition to any cell's single-click action message. The double-click action of an NSMatrix
object is always sent to its target.
Copyright © 2002, 2016 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2016-09-13