image icon before text in outline view

I want to display an image icon before the text in every row of outline view.
I am unable to do that Please suggest me something.

I believe you can just “set image” for a row in the methods where the value of the row is entered into the outline view. You can use the search to find how to get and image and set it if you’re not sure.

I was not able to succeed the way you told me and i didn’t get you even how to proceed further. Please let me know detailed steps to proceed further. The image and text has to appear in the same column like the same thing in the Finder which show folder images.

This is what i am using:-

on awake from nib theObject

set fgh to {{"Shivank1"}, {"Shivank2"}, {"Shivank3"}, {"Shivank4"}}
set content of theObject to fgh

on clicked theObject
set result1 to clicked row of theObject

set theDefaultImage to load image "Macintosh HD:Users:Apple:Pictures:iChat Icons:Flags:Argentina.gif"
set image of clicked row of theObject to theDefaultImage

end clicked

I am still getting error .Please suggest me something to resolve this approch asap.

Thanks In Advance,
Shivank

My mistake, you can’t set an image the way I suggested. I was thinking of a browser, not an outline view. Anyway it shouldn’t be too hard. An outline view is like a table view. So when I add an image to a table view I add a column in IB to the table. Normally it gets a “text cell” in the table column automatically. You change the text cell to an image cell (just drag/drop an image cell on the column) for the column, then you can add an image to that column for that row.

This looks wrong to me. I think the path to an image must be a posix path so the “load image” line should be this…
set theDefaultImage to load image posix path of (“Macintosh HD:Users:Apple:Pictures:iChat Icons:Flags:Argentina.gif”)

Yes the same thing i was trying to say you that it is not possible using set image command.

Actually in the table view or outline view we can set a image in an another column but i want both the image and text in the same column so that when the tree expands the image and text doesn’t go apart and remains together like the Finder application.

There is no such cell in the which provides us to have image and text together in one column. Please let me know if you have any suggestions…

If you know some objective-c, there is a way. There’s an example project here:
/Developer/Examples/AppKit/DragNDropOutlineView/

Inside that project is a class called “ImageAndTextCell” which would do what you want. So if you have the knowledge then you could probably use that in your applescript project.

Hello,

I’d like to know how you go about showing an image file in another column. This is what Ive been trying to do.
Actually I’m trying to show the icon of the file in a column, but there is no way to do that.

I did find regulus6633"s qlpreview creation but it just doesnt work in my script. Plus that’s not exactly what I’m trying to do, I dont want to export those images, only show them in the rows.

Any help ?

Thanks :slight_smile:

PS : I’m trying to integrate qlpreview into my project, maybe this is why it’s working out for me…

I’ve been looking at this example in Xcode and torturing myself trying to adapt it to my needs in my table view :/.
I got nothing, I don’t know enough Obj-C I guess (still dont know much to be honest!)

I’m sure I could use a “call method” somewhere in there, in my on drop handler, but I don’t know with what parameters or anything.
Anyways, I imported the .h and .m classes to my project but I can"t figure out how to load an image in my table view for the life of me.

Can anyone help me out a little please?

Thanks in advance…

You don’t need any call method code. What you need to do is make the actual cell in interface builder that class. So in interface builder select the actual cell in your table… not the table column, but the actual table cell. When you select it only the words “text cell” will be highlighted. Then in the inspector window go to the section called “Text Field Cell Identity”. It will say that at the top of the inspector window. Look at the class section, it will say NSTextFieldCell. Change that to ImageAndTextCell.

That’s it. Now you can tell the cell to “set image” to some image.

Awesome, looks like I’m getting closer …

But what would the code look like then, in AS ?

Getting so confused here :expressionless: none of the code lines I’ve tried in my on drop handler even compile …

set folderImage to (load image "folder")
set data cell "image" of table view 1 of scroll view 1 of window "ItemList" to folderImage

something like taht ? it says that it’s impossible to set «class datC» “image” to «class imaA» id 164. (-10006)

I don’t have any code for that in applescript but you would have to get a reference to the cell and then set a loaded image to that cell… something like…

set myImage to load image whatever
set theCell to cell whatever of table view whatever of …
set image of theCell to myImage

Alright I think Im just going to give up here. Ive been trying for days and found NOTHING online, and im just getting irritated with myself.

I cant find the right code to relate to an image cell or data cell anywhere.


        set folderImage to (load image "folder.png")
	display dialog "OK" with icon "folder" -- this proves that the image is loaded OK
	set theCell to (cell "image" of data source of table view 1 of scroll view 1 of window "ItemList") -- error here
	display dialog "OK" -- this dialog never shows
       set image of theCell to folderImage

returns an error too…

:mad: