Hey everyone,
I am trying a few new things out in applescript studio and I made an app that has 2 buttons and when one of them is pressed a sheet is supposed to pop out with a text field and three buttons. I am trying to get the button pressed and then perform another action, in this case opening a file open window, but I keep getting a variable not defined error, any here would be great, here is the code:
edit: I just tried this code as script by itself and it works, could it have something to do with it being attached as a sheet?
edit #2: so it works as long as it is not attached as a sheet, seems kind of odd to me, i think it looks better when it is a sheet, but I'll live
I am trying a few new things out in applescript studio and I made an app that has 2 buttons and when one of them is pressed a sheet is supposed to pop out with a text field and three buttons. I am trying to get the button pressed and then perform another action, in this case opening a file open window, but I keep getting a variable not defined error, any here would be great, here is the code:
Code:
property dialogResult : {}
on clicked theObject
if title of theObject = "Hi" then
--tell application "TextEdit"
set new_file to choose file with prompt "Open file to be edited" of type (".txt")
open new_file
--end tell
else if title of theObject = "Bye" then
-- Starts the dialog at the bebinning of the script
set dialogResult to display dialog "Enter the project name:" default answer "Project" buttons {"Load...", "Cancel", "Ok"} attached to window "main"
if button returned of dialogResult is "Load..." then
set new_file to choose file with prompt "Open file to be edited" of type (".txt")
end if
end if
end clicked
edit: I just tried this code as script by itself and it works, could it have something to do with it being attached as a sheet?
edit #2: so it works as long as it is not attached as a sheet, seems kind of odd to me, i think it looks better when it is a sheet, but I'll live