Re: NSCells embedded in NSCell?
Re: NSCells embedded in NSCell?
- Subject: Re: NSCells embedded in NSCell?
- From: Daniel Jalkut <email@hidden>
- Date: Fri, 15 Sep 2006 12:33:23 -0400
The basic strategy I have adopted when doing this is to keep around
instances of the composed cells to do all the dirty work of actually
drawing and tracking. It's important to keep in mind that cells don't
"live" anywhere. When you talk of "actually embedding the cells,"
this is a mistaken concept. Cells are asked to draw and asked to
manage user interaction at certain points on the screen, on behalf of
some owning view.
So when the owning view asks your *custom cell* to handle either
drawing or mouse tracking, you're going to decide which of your
subcells to dispatch to and let them take care of the operation.
For drawing, this means simply asking each of the composed cells to
draw, in turn, at whatever portion of your screen real estate (the
cellFrame passed to drawInteriorWithFrame) you deem appropriate. For
instance if I've got an image cell that is part of my composition,
I'll call something like this:
[mImageCell drawWithFrame:myImageRect inView:controlView];
For tracking, you will likewise pass control through to the cell when
tracking is required, for instance in your subclass override of
trackMouse:... you will need to determine for yourself (based on
where you've decided to draw the subcell) whether the mouse click
corresponds to that cell's location. Then you'll call through:
[targetCell highlight:YES withFrame:cellFrame inView:controlView];
trackResult = [targetCell trackMouse:theEvent inRect:cellFrame
ofView:controlView untilMouseUp:flag];
[targetCell highlight:NO withFrame:cellFrame inView:controlView];
This article may help put things into even more perspective:
http://www.stepwise.com/Articles/Technical/NSCell.html
Good luck!
Daniel
On Sep 15, 2006, at 9:52 AM, Dan Donaldson wrote:
What are the basics of embedding multiple NSCells in a containing
NSCell?
I need to place a multiline text object, with a popupbutton at the
top in a cell. The behaviour of each of the two Cell objects is
pretty standard, but they need to be contained in a single cell of
an NSOutline.
I'm assuming I override drawInteriorWithFrame: inView: . But in
that case, how do I actually embed the NSCells? Do I set up a set
of bounding rectangles, and then -- what? Can't find any examples
of NSCells contained by an NSCell, but it's been suggested to me
that this is the way to do it.
Just to head it off, I'm trying to avoid having two separate cells
for this. Obviously, recreating an NSPopupButton is too much to do,
but would the other option be to add a text field to a subclass of
it? This wasn't what I thought of first, because the cell may
eventually have to have further, complex NSCell type objects in it,
so it would be only deferring pain....
any suggestions/sample code sources?
TIA
Dan Donaldson
dan[i'm at]omnivore[little black mark]ca
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
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