Load image dispaly open panel..

help i have this problem :frowning:
i need to load image in to image view via --display open panel attached to window of theObject-- :

this not work for me

on clicked theObject
if name of theObject is "downloads_button" then
		set tmpPath to display open panel attached to window of theObject
		set theImage to load image tmpPath
		set image of image view "userImage" of window "main" to theImage
end clicked

This work

if name of theObject is "downloads_button" then
		set tmpPath to chose file
		set theImage to load image tmpPath
		set image of image view "userImage" of window "main" to theImage

someone have idea load one image using to display open panel attached to window of theObject

Model: G5 DP 2700
AppleScript: 2.1
Browser: Safari 412.2.2
Operating System: Mac OS X (10.4)

Having the open panel attached to a window requires that you separate the functions of opening the open panel and dealing with the results of the open panel. When the user is done selecting the image file, the app then calls the function “on panel ended theObject with result withResult”. It will be in the panel ended handler that you will load the image.

on panel ended theObject with result withResult
    if withResult is 1 then
        set image of image view "userImage" of window "main" to load image (path name of open panel)
    end if
end panel ended

Thanx :frowning:

i replace my code in this mode and not work:( :frowning:


on clicked theObject
	
	if name of theObject is "downloads_theme" then
		display open panel attached to window of theObject		
	end if
	end clicked
on panel ended theObject with result withResult
	if withResult is 1 then
		set image of image view "userImage" of window "main" to load image (path name of open panel)
	end if
end panel ended

someone have idea for this…

Model: G5-2700
AppleScript: 2.1
Browser: Safari 412.2
Operating System: Mac OS X (10.4)

I tested the following code in a quick app I threw together and it worked. It may have been that “load image (path name of open panel)” line because that didn’t work for me.

Also, have you connected window “main” to the panel ended handler in IB?

on clicked theObject
	if name of theObject is "choose" then
		set can choose files of open panel to true
		set can choose directories of open panel to false
		display open panel attached to window of theObject
	end if
end clicked

on panel ended theObject with result withResult
	if withResult is 1 then
		set imagePath to path name of open panel
		set image of image view "imageView" of window "main" to load image imagePath
	end if
end panel ended

Very Very THANX for your help Joseph Briggs

the code work now GOOD for my Application :smiley:

Model: G5 DP 2700
AppleScript: 2.1
Browser: Safari 412.2.2
Operating System: Mac OS X (10.4)