Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The point of <code>NSCell</code> subclasses is to separate responsibility for rendering and handling common UI elements (the controls) from the visual- and event-hierarchy responsibilities of the <code>NSView</code> classes. This pairing permits each one to provide greater specialization and variability without burdening the other. Look at the large number of <code>NSButton</code> instances one can create in Cocoa. Imagine the number of <code>NSButton</code> sub-classes that would exist if this split in functionality were absent!</p> <p>Using design pattern language to describe the roles: an <code>NSControl</code> acts as a façade, hiding details of its composition from its clients and passing events and rendering messages to its <code>NSCell</code> instance which acts as a delegate.</p> <p>Because your <code>NSCell</code> subclass includes other <code>NSCell</code> subclass instances within its composition, they no longer directly receive these event messages from the <code>NSControl</code> instance which is in the view hierarchy. Thus, in order for these cell instances to receive event messages from the event responder chain (of the view hierarchy), your cell instance needs to pass along those relevant events. You are recreating the work of the <code>NSView</code> hierarchy.</p> <p>This isn't necessarily a bad thing. By replicating the behavior of <code>NSControl</code> (and its <code>NSView</code> superclass) but in an <code>NSCell</code> form, you can filter the events passed on to your sub-cells by location, event type, or other criteria. The drawback is replicating the work of <code>NSView/NSControl</code> in building the filtering &amp; management mechanism.</p> <p>So in designing your interface, you need to consider whether the <code>NSButtonCell</code> (and <code>NSTextFieldCell</code>s) are better off in <code>NSControl</code>s in the normal view hierarchy, or as sub-cells in your <code>NSCell</code> subclass. It's better to leverage the functionality which already exists for you in a codebase than to re-invent it (and continue maintaining it later) unnecessarily.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload