• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Implementing control with multiple cells
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing control with multiple cells


  • Subject: Re: Implementing control with multiple cells
  • From: Erik Buck <email@hidden>
  • Date: Sun, 7 May 2006 20:01:51 -0400

I'm trying to create a NSControl subclass contains multiple cells
(NSActionCell subclass). But my question is, it seems NSControl can only
work with one cell out of the box. Does it mean I'll need to override
methods like drawRect (to call drawInFrame:) and mouseDown (to call

How would NSControl know how or where to draw your multiple cells ? Yes, you will have to implement -drawRect: in your NSControl subclass to call -drawWithFrame:inView:.


trackMouse:) to support multiple cells? And also instantiate the cells
myself as opposed to overriding +cellClass.

How would NSControl know how many of your cells to instantiate ? Yes, you are likely going to have to implement cell instance creation in your subclass of NSControl. There are several options. One is to allow users of your class to dynamically add cells. Look and NSMatrix to see how NSMatrix copies a prototype cell and/or creates instances of the class returned from +cellClass.


You might also consider reusing the same cell over and over in your NSControl subclass the way NSTableView does. That is a nice solution when cell type and formatting don't change often but the where the cell is drawn does.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: filling NSImage with binary data from NSData
  • Next by Date: -[NSEvent window] for NSPeriodic event?
  • Previous by thread: Implementing control with multiple cells
  • Next by thread: -[NSEvent window] for NSPeriodic event?
  • Index(es):
    • Date
    • Thread