open panel,problems with results

Hello I am having troubles with the open panel class… here is my code


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

on panel ended theObject with result withResult
	if withResult is 1 then
		set theFolder to item 1 of (path names of open panel as list)
		set contents of text field "fileresultbox" of window "window" to theFolder
		
	end if
	end panel ended 

what I want to happen is for a panel to open, the user to select a dir. then for this dir to be displayed in the text field fileresultbox…The code compiles without errors. but the result is not displayed in the text field after the user selects it within the open panel…Thank you for any advice!

-jay

I don’t know if you got this answered. I was having the same problem and posted a similar question. Meanwhile I started doing more debugging using the log command for each event handler and found that the event handler “on panel ended” was never being called.

In order for my preferences window to execute the code in the event handler “on panel ended”, I had to tell the window in Interface builder to process that event by checking off the panel ended (under panel) event handler and then selecting the name of the script file below. (This is all under the applescript option in the “Show Info” window.)

I hope this is helpful.