Image in an outline view

Is there any way to show images in an outline view?

How can I load images into the cells in an outline view, along with the text, such as the document and folder icons we see next to the names in the outline view in the Finder, or the mailbox icons next to the mailbox names in the outline view we see in Mail, etc?

I can load images into an image cell in a table view, by basically:

set contents of data cell 1 in data row 2 in data source of table view "MyTableView" to (load image "MyImage")

The dictionary shows that a cell in a table or outline view has an image property. I’m concluding that I can only access the properties of cell via the “will display item cell” handler, which won’t be called if the outline has a data source. I tried modifying the “Outline” example project by adding a “will display item cell” handler:

property testImage : null

on launched theObject
	-- other stuff here
	set testImage to load image "Minus" -- an image file I added to the project
end launched

on will display item cell theObject cell theCell table column tableColumn outline item outlineItem
	tell theCell
		set bordered to true
		set image of it to testImage
	end tell
end will display item cell

Te “set bordered” works, but the “set image” gives an error “AppleEvent handler failed. (-10000)”.

Is there any way to show images in an outline view?

Thanks,
Tom
BareFeet

There are two ways…

  1. Make an extra column in your outline view that holds icons for your items. This is rather ugly, because the icons won’t be aligned next to your items, they’ll be off to the side, and will gradually get further and further from your item name as you expand the hierarchy.

  2. Google “imageandtextcell”, and you’ll find an example project at apple developer that provides a prototype cell subclass you can use. Apple has so graciously provided us with the basics we need to add an icon to a table cell, but you’ll have to make it work for you using obj-c. If you’re not comfortable with obj-c you’ll have a hard time implementing it… especially if you’re trying to make your ASStudio data source work with the obj-c. I have yet to implement this class in an ASStudio project and have it be acceptable in terms of appearance and performance.

Take your pick.

BTW, you can only set the image of a table cell if it’s an image cell. The default cell is a text cell, so it doesn’t have an image property.