Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
- Subject: Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
- From: Mike Abdullah <email@hidden>
- Date: Fri, 20 Oct 2006 11:44:40 +0100
Have you properly implemented your new cell's copyWithZone: method?
NSCells get copied a lot when being drawn. If you don't implement
this, the table view will copy your cell incorrectly and screw up
your memory management.
Mike.
On 19 Oct 2006, at 21:13, Dan Donaldson wrote:
I have an NSTextField subclass. Its function is to provide a cell
with two vertically stacked text areas in one cell.
Things are generally working ok, its being instantiated, put into a
column in an NSOutlineView. I've shifted the default text area down
18.0 pixels, to leave space for the upper textfield. This is an
NSTextFieldCell, stored in an instance variable called titleField
in the cell. This is being created on init of the cell, and that's
confirmed using NSLog.
When I try to draw the extra cell, I use this:
// -----------------------------
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView {
NSSize titleSize;
NSRect titleFrame;
titleSize.width = 300.0;
titleSize.height = 18.0;
NSDivideRect
(cellFrame,&titleFrame,&cellFrame,titleSize.height,NSMinYEdge);
NSLog(@"frames: \rcell x: %f y: %f w:%f h:%f \r\r title: x: %f y: %
f w:%f h:%f",
cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width,
cellFrame.size.height,
titleFrame.origin.x, titleFrame.origin.y,
titleFrame.size.width, titleFrame.size.height);
if ( titleField != nil) {
[titleField drawWithFrame:titleFrame inView:controlView];
}
[super drawWithFrame:cellFrame inView:controlView];
}
and the application crashes. I'm not very experienced with Cocoa,
but this seems reasonable. The frames are both there, but it isn't
working...nothing has been done with titleFrame except alloc/init/
autorelease. cellSize is being used to manipulate the row height
correctly.
Help (please)...
Dan Donaldson
416 604 3398
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:
40gmail.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