Image Cell

Hello:

is it me or is there close to no information on how to use an NSImageCell in a table view. In the new panther interface builder it allows you to drag and drop NSImageCell on to a column, but I can’t seem to figure out how to associate an image with the a cell or column. The documentation tells you what it is, but doesn’t give an example on how to use it.

Any Ideas? Thanks

-d

Assuming you have a table view “images” in a scroll view “images” in the window “main” linked to a data source with a data column named “image”, and you have added the appropriate image cell to the column in IB, try adding this code to an “on clicked” event for a specific button:

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]

ooohhhhhhh jonn8 god of the applescript…

sorry about all the questions… just trying to wrap my head around applescript development.

So you answered my question on changing data sources in a table. Now I have a need for a common image to be part of that data source.

Basically my first column is an informational column then my second column will be a simple graphic that points to the third column, like…

4 -----> 547

obviously I could just use text like I did in the above example. But what would be graphically better is to have a PNG file of an arrow instead of text. What’s the best way to do this for every row containing data?

Also I’ve been looking at panther xcode interface builder and when you add a NSimageCell to a column and then click the image cell triangle… under attributes there is a Text field named “Image”… but no matter what I put in that field nothing sticks… I can type anything in that field, but It never stays. So what is that field for???

Just trying to find the answers, thanks

-d

All you have to do is add an image to your project (just drag an image file from the Finder into your project’s “Resources” folder in the “Groups & Files” column in Xcode or Project Builder and then make sure you select “Copy items into destination…”). Then, when you want to reference that image, you just use the image name, not the extension. I’ve updated the demo project I created for the data swap to include an arrow image that gets added to every data row on the swap:

TableDataSwap.hqx

Jon

Not very relevant to the original question, but more about the TableDataSwap project. I’ve done very similar things only that I have 8 different tables with some of them can grow a bit bigger, so deleting and reloading data source every time the tables are swapped is a bit impractical (slow).

My solution is brute=force: just use 8 tables, each of them has its own data source. In IB they are all stacked on top of each other. In code, when swapping, I just manipulate the “visible” property of them so only one of them is visible at any point in time.