I can’t seem to get this to work.
I want to be able to select only one folder in an open panel and then display the name of that panel in a display dialog.
on clicked btnAdd
set can choose directories of open panel to true
set can choose files of open panel to false
set allows multiple selection of open panel to false
display open panel attached to window "Backup"
end clicked
on panel ended btnAdd with result retChosen
if retChosen is 1 then
set retFolder to path names of open panel
display dialog retFolder attached to window "Backup"
end if
end panel ended
Model: iBook 12"
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
What part of that are you having a problem with? You should post the error(s) you’re getting; If there isn’t an error, then you should say so.
Have you tried running your app inside Xcode and using the log
command to see what kind of values you’re getting? The problem is that the dialog can not display a list, which is what path names
returns. You could treat this a regular list (first item of .), or you could use something like this:
on clicked theObject
tell open panel
set can choose files to false
set can choose directories to true
set allows multiple selection to false
end tell
display open panel attached to window "main"
end clicked
on panel ended btnAdd with result retChosen
if retChosen is 1 then
set retFolder to path name of open panel
display dialog retFolder attached to window "main"
end if
end panel ended
Note the absence of the “s” from path name
.
See also: open-panel Class
Yeah, I have been reading on the open-panel class all of yesterday.
I found out my problem. I didn’t have Applescript enabled for panel close.