cocoa-scripting

How to pass an arbitrary AppleScript Record to Cocoa in a scriptable app?

可紊 提交于 2020-01-12 08:28:11
问题 I have a Cocoa application with an AppleScript dictionary described in a .sdef XML file. All of the AppleScript classes, commands, etc. defined in the sdef are working property. Except for my "submit form" command. The "submit form" command is my only command attempting to pass a parameter that is an arbitrary hashtable of information from AppleScript to Cocoa. I assume this should be done by passing an AppleScript record which will be automatically converted to an NSDictionary on the Cocoa

Support “styled text” in a scriptable Mac application (Cocoa Scripting)

。_饼干妹妹 提交于 2020-01-06 04:02:06
问题 My app supports being scripted with Applescript. I am trying to make styled text content, stored in NSAttributedString objects, available to an Applescript user. I thought I could simply deliver styled text with the NSAttributedString class, just like I deliver plain text with the NSString class, but that does not work - Cocoa Scripting then reports that it cannot convert or coerce the data. I wonder if I'm missing something or if this is just plain impossible with the standard classes

Add scriptable property to Cocoa application derived from NSObject <NSApplicationDelegate>?

 ̄綄美尐妖づ 提交于 2019-12-13 07:36:47
问题 Can someone point me to an example of this working. I just want to set a property value via AppleScript. I have gone through all of the scriptable examples, which are setup differently. <?xml version="1.0" encoding="UTF-8"?> <dictionary title=""> <suite name="Circle View Scripting" code="bccS" description="Commands and classes for Circle View Scripting"> <class name="application" code="capp" description="" > <cocoa class="NSApplication"/> <property name="circletext" code="crtx" type="text"

Cocoa Scripting: Returning “null” vs. “missing value”

时间秒杀一切 提交于 2019-12-08 00:21:40
问题 It appears that AppleScript knows the special value null . How do I return such a value from my Cocoa Scripting based app for a scriptable property? If I return nil ( NULL ) or NSNull for a scriptable property getter from my Cocoa Scripting-based app, the script editor interprets that as missing value . And if I return [NSAppleEventDescriptor nullDescriptor] , AppleScript even shows an error. 回答1: AppleScript uses a typeNull descriptor to indicate unassigned/no value, whereas missing value is

Cocoa Scripting: Accept and return NSData

吃可爱长大的小学妹 提交于 2019-12-07 11:30:27
问题 In order to support binary data exchange in my scriptable Mac app, I like to make it possible to receive and deliver data as NSData, using the AS-ObjC bridge, if that's possible. For instance, I like to make this code possible in AppleScript: use framework "Foundation" set theData to current application's NSData's dataWithContentsOfFile:"/some/binary/file" tell application "MyApp" set raw value to theData end tell The sdef contains a value-type and property for this: <suite name="My Suite"

Cocoa Scripting: Returning “null” vs. “missing value”

六月ゝ 毕业季﹏ 提交于 2019-12-06 11:22:24
It appears that AppleScript knows the special value null . How do I return such a value from my Cocoa Scripting based app for a scriptable property? If I return nil ( NULL ) or NSNull for a scriptable property getter from my Cocoa Scripting-based app, the script editor interprets that as missing value . And if I return [NSAppleEventDescriptor nullDescriptor] , AppleScript even shows an error. AppleScript uses a typeNull descriptor to indicate unassigned/no value, whereas missing value is represented by a typeType descriptor of cMissingValue . (It's analogous to the undefined vs null mess in

Cocoa Scripting: Accept and return NSData

流过昼夜 提交于 2019-12-05 15:04:58
In order to support binary data exchange in my scriptable Mac app, I like to make it possible to receive and deliver data as NSData, using the AS-ObjC bridge, if that's possible. For instance, I like to make this code possible in AppleScript: use framework "Foundation" set theData to current application's NSData's dataWithContentsOfFile:"/some/binary/file" tell application "MyApp" set raw value to theData end tell The sdef contains a value-type and property for this: <suite name="My Suite" code="Demo"> <value-type name="ObjCNSData" code="NSDa"> <cocoa class="NSData"/> </value-type> <class name

How to pass an arbitrary AppleScript Record to Cocoa in a scriptable app?

若如初见. 提交于 2019-12-03 16:10:34
I have a Cocoa application with an AppleScript dictionary described in a .sdef XML file. All of the AppleScript classes, commands, etc. defined in the sdef are working property. Except for my "submit form" command. The "submit form" command is my only command attempting to pass a parameter that is an arbitrary hashtable of information from AppleScript to Cocoa. I assume this should be done by passing an AppleScript record which will be automatically converted to an NSDictionary on the Cocoa side. tell application "Fluidium" tell selected tab of browser window 1 submit form with name "foo" with

Cocoa Scripting: Returning the cloned objects from a “duplicate” command

隐身守侯 提交于 2019-12-02 14:59:25
问题 The AppleScript duplicate command is supposed to return the copied objects. And while apps using the original AE-based functions seem to do that, apps based on the Cocoa Scripting framework seem to never return anything but missing value . It appears that the command handler of NSCloneCommand is responsible for not returning the specifiers for the cloned objects. I was attempting to fix this in my scriptable app by subclassing the command, collecting the cloned object specifiers and then