As per the initial description of your problem, you just want to change the image of the cell when it is clicked(selected) right?

If thats the case then you don't have to deal with checking the image name etc. neither u have to do the setImage stuff in outlineviewSelectionDidChange What you do is in the willdisplayCell method, check if the cell being displayed is for the selectd (clicked) row, if it is then change it's image else set the default image
here is the code snippet for the same

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell: (id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
        if ([[tableColumn identifier] isEqualToString:@"firstColumn"])
        {
// If the cell being displayed is for the selected row, change it's image
                if ([outlineView itemAtRow:[outlineView selectedRow]] == item)
[(ImageAndTextCell *)cell setImage:[NSImage imageNamed:"checkbox_click.gif"]];
                // Else display the default image
                else
[(ImageAndTextCell *)cell setImage:[NSImage imageNamed:@"checkbox_none.gif"]];
        }
}

hth,
Chaitanya

On 01-Sep-08, at 5:59 PM, [EMAIL PROTECTED] wrote:

Thanks for your consideration,
In the willDisplayCell i did like:
if ([[tableColumn identifier] isEqualToString:@"firstColumn"])
{
       NSString *imageName = nil;
        NSImage *image = nil;
       imageName = @"checkbox_none.gif";
       image = [NSImage imageNamed:imageName];
        ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
       [imageAndTextCell setImage:image];
}

And in the outlineViewSelectionDidChange method Idid like:

     id cell = [[[OutlineView tableColumns] objectAtIndex:0]
                  dataCellForRow:[OutlineView selectedRow]];
        NSString *imageName = nil;
        NSImage *image = nil;
        id Name = [[cell image]name];
        if([Name isEqualToString:@"checkbox_none.gif"])
        {
              imageName = @"checkbox_click.gif";
              image = [NSImage imageNamed:imageName];
              ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
              [imageAndTextCell setImage:image];
        }
        else
        {     imageName = @"checkbox_none.gif";
              image = [NSImage imageNamed:imageName];
              ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell;
              [imageAndTextCell setImage:image];

        }
        [OutlineView reloadData];

But it only work for root nodes.When I clicking on child nodes,image is
changing in root node. Where I got wrong ? How can I implement it in
willDisplay method ?

Thanks in advance.





The right place to change the image of the cell would be in the
outlineView's delegate method:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:
(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

 try [[cell image] name] to get the name of the image
-chaitanya

On 29-Aug-08, at 5:41 PM, [EMAIL PROTECTED] wrote:

Hi all,
I'm trying to develop an application that uses an OutlineView in
which it
displays items like a disclosure triangle, then one checkbox, then a
text
field int the same column. For that I gone through the
DragNDropOutlineview example provided with Xcode. Then I copied the
ImageAndTextCell class and uses two images, one is checked and other
is
unchecked. Now the application works with showing one image.I want to
change the image when clicking on it. How can I do that ?. In which
method
I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it
faild.
When I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
        id info = [cell image];
        NSLog(@" %@",info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click
Size={13,
13} Reps=(
  NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13
Alpha=NO Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?

Thanks in advance

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com

This email sent to [EMAIL PROTECTED]





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to