The code from the Sdef (not including the Standard Suite):
<suite name="Da Suite" code="daSu" description="This is a suite that DOES NOT WORK FOR SOME REASON!!!">
<class name="Application Class" code="appC" inherits="application">
<cocoa class="NSApplication"/>
<property name="theText" code="theT" description="some text." type="text">
<cocoa key="theText"/>
</property>
</class>
</suite>
</dictionary>
Well, that didn’t work either. This is what I have in the App Delegate:
property theProp : "Hello"
on application_delegateHandlesKey_(sender, theKey)
if theKey = "theText" then
return theProp
end if
return "error"
end application_delegateHandlesKey_
What I am having trouble understanding is the tutorial mentioned in my last post. It’s in Objective-C, but look at the application delegateHandlesKey section. They return a boolean even though the information is more than a boolean.
What was the AppleScript command you used to get the variable? It is still not working. I might have to open up a new app and paste my code from this website in…
tell application "ScriptingTest"
activate
set p to theText
end tell
That’s the whole script.
This is the whole script in the Xcode project:
script ScriptingTestAppDelegate
property parent : class "NSObject"
property theText : "This is my text"
on application_delegateHandlesKey_(sender, theKey)
if theKey as string = "theText" then
return true
end if
return false
end application_delegateHandlesKey_
end script
Well, I made a new application and pasted the code from this webpage (besides the sdef code) in it and IT WORKED!!! Thank you rdelmar!
Now I am trying to be able so set theText. When I do “set theText to” and then put a string It tells me it can’t set theText to the string. In the sdef the permission is read/write, but I know I’m doing something wrong. Does anyone know how to set a property, not just get one?
Did you change the .sdef from what you posted? There isn’t any r/w permission set in there. But when I run it with the sdef you posted above, it lets me set theText. I changed the applescript to:
tell application "ScriptingTest"
activate
set p to theText
delay 5
set theText to "New Text"
set q to theText
delay 5
end tell
I get this in the log:
tell application “ScriptingTest”
activate
get theText
→ “This is my text”
set theText to “New Text”
get theText
→ “New Text”
end tell
Yes, I know, that’s why I started that sentence with “but” – perhaps r/w access is the default. In any case, it works in my hands, so I don’t know what’s going on with your script.