Re: difficulties with NSCell -setImage method
Re: difficulties with NSCell -setImage method
- Subject: Re: difficulties with NSCell -setImage method
- From: Max Horn <email@hidden>
- Date: Fri, 7 Dec 2001 15:05:19 +0100
At 3:59 Uhr -0500 07.12.2001, Alex Reynolds wrote:
I am attempting to overload the -willDisplayOutlineCell method for
outline views, to redraw my custom "expanded/not-expanded" graphics.
It works okay, with the one problem that when the very first item
has a child added, it becomes expandible and has a system-default
triangle drawn to the outline cell, instead of my custom
"non-expanded" or "closed" graphic.
Did you check if your method is being called in that case at all?
If I click on the expansion triangle, the method below works
properly to draw my custom "expanded" or "open" graphic.
If I then close the triangle, the method below draws the
"non-expanded" custom graphic properly. Opening and closing nodes
works properly from then on.
Is there any way I can fix this so that the custom graphic is drawn
the first time around, instead of the system default?
My code for -willDisplayOutlineCell is as follows:
- (BOOL) outlineView: (NSOutlineView *) outlineView
willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn
*)tableColumn item:(id)item
This is conflicting with the actual definition of this method!
{
//
// these are NSButtonCell objects...
//
if ([outlineView isItemExpanded:item])
{
// NSLog (@"Item is expanded");
[cell setAlternateImage:openImage];
[cell setImagePosition:NSImageAbove];
}
else
{
// NSLog (@"Item is closed");
[cell setImage:closedImage];
[outlineView updateCell:cell];
}
return YES;
}
This code works fine for me:
- (void) outlineView: (NSOutlineView *) outlineView
willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn
*)tableColumn item:(id)item
{
//
// these are NSButtonCell objects...
//
[cell setImage:closedImage];
[cell setAlternateImage:openImage];
[cell setImagePosition:NSImageAbove];
return YES;
}
Cheers,
Max
--
-----------------------------------------------
Max Horn
Software Developer
email: <
mailto:email@hidden>
phone: (+49) 6151-494890