scriptable app won't return boolean property

Hi All,

I have a simple scriptable setup in my app to run a command and retrieve a couple properties. I did this easily with the Help of Shane’s new, superb, AppleScriptObjC Explored 5.

I can access the text properties but not the boolean.

in sdef I have “backupactive” property with key “backupProgress”:

<property name="backupactive" code="blIR" type="boolean" access="rw" description="Is a set running.">
		<cocoa key="backupProgress"/>
</property>

I have

property backup active:false

on |application|:theApp delegateHandlesKey:theKey
 if (theKey as text) is in {"backupProgress", "setNamed"} then
	return true
	else
	return false
 end if
end |application|:delegateHandlesKey:

the dictionary shows all as fine and the other properties can be got easily. The backupactive word compiles in script editor but when run I get an apple events error with no explanation (of course)

Did I configure this wrong or do I have to create a new Objc class (parent NSApplication) with the getter method for backupactive? Would prefer to keep it so nice and simple as in Shane’s scripting example, though I noticed he doesn’t have a boolean property in there…

Thanks, Rob

Hi,

the delegateHandlesKey method is called to confirm that the delegate (aka the application) is able to provide the properties for the specific keys.

You need also to declare a property backupProgress with a default true or false value

You can simplify the delegateHandlesKey method this way


on |application|:theApp delegateHandlesKey:theKey
	return (theKey as text) is in {"backupProgress", "setNamed"}
end |application|:delegateHandlesKey:

Excellent. That’s it. I didn’t think you had to have a property for the key itself just the property name value. But it works.

Thanks Stefan