Window name as Hierarchy to current file

Hi all, I am taking the plunge into Applescript Studio and xcode,

So here is one of most likely many questions.

Can I, with Applescript Studio have the window name (Title) linked to my current file (loaded image ).
I.e when you command click the window name/title bar, a drop-down of the file Hierarchy is shown.
Of cause I would also like the title to show the icon and name of the file.

Thanks for any help

Mark, I don’t know how to do this but it seems to me that it may be very similar to my recent problem here. Look at my post #8 for instructions to my solution.

It seems to me that your hierarchal path is just a list, just like my recent searches list. So maybe if you create a new menu like I described and figure how to link it to the top of the window (or file’s owner or something like that) maybe it would work. Anyway, it’s just a thought.

Good luck.

property imageView : null

on awake from nib theObject
	if name of theObject is "imageView" then
		set imageView to theObject
	end if
end awake from nib

on clicked theObject
	if name of theObject is "setImage" then
		set filePath to POSIX path of ((choose file without invisibles) as string)
		set fileName to call method "lastPathComponent" of filePath
		
		delete image of imageView
		set image of imageView to (load image filePath)
		
		tell window "window"
			set associated file name to filePath
			set title to fileName
		end tell
	end if
end clicked

I can’t speak from experience, but I think a “Document-based Application” might do that automatically. If that’s not appropriate for your app, then try jobu’s code.

regulus, Bruce , Jobu,

Thank you all for the responses.

Jobu, I used a snippit from your script ,

set associated file name to filePath
           set title to fileName

Which worked great, Thanks. :slight_smile:

Bruce, I have written most of my app, so did not want to re-incorporate it into a Document App.
But I will look at it anyway with some test scripts to see what the differences are ??.

Regulus, I think I need to get my head around the call methods a bit more, And I thing your post will help.

Thanks again.

Mark

Jobu, that’s so beautiful! I just put that in my app too. It’s great, thanks. :slight_smile:

If I understand correctly, what you’re describing is just the default behavior of all document based applications. It works this way in Pages, iWork, TextEdit and so on. The whole document management side of things is handled by the OS (Cocoa), including command clicking to navigate the path, dragging the window title’s icon into the Finder to copy the file, showing the icon of the file in the window title, updating the “Open Recent” menu in the File menu and so on.

The good news is that you get all this functionality simply by creating a Document Based Application in XCode. It works fine for an AppleScript application (document based). You can instead in Interface Builder manually link up a window in an existing Xcode project to be the document for that application, but it’s a bit fiddly.

I suggest you don’t reinvent the wheel since you’ll only get half the user experience working and your program won’t be consistent with the Mac look & feel.

Tom
BareFeet