Questions tagged [cocoa-scripting]

Cocoa Scripting is a framework for OS X for making applications scriptable

Use this tag for questions related to making an OS X application scriptable, i.e. when you write your code in Objective-C or in Swift.

Do not use it for questions related to writing code in AppleScript or JavaScript (JXA) - for those, use the applescript or the cocoascript tag.

26 questions
1
vote
1 answer

Cocoa Scripting: How do I use AppleScript handlers (events)?

Adding scriptability to my Mac app, I wonder if I can invoke handlers on the script's end from my app. If so, how does that work? As I understand it, handlers are like functions (as in "on run") that can be called by events coming from outside of…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
1
vote
1 answer

Cocoa Scripting: "whose clause" cannot access certain properties

I am working on making my application scriptable. I struggle with the "whose" filter clause. I want to make this work, but while name can be used, country can not: tell application "myapp" get every city whose name is "Berlin" -- works get…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
1
vote
3 answers

Cocoa Scripting: Use special string types like raw data

My app has some raw data content I want to be able to offer to AppleScript so that it can be at least looked at, if not even handled by saving it to a file or setting it to some other object that supports it. Now, I don't understand which data type…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
1
vote
2 answers

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

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…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
1
vote
2 answers

Cocoa Scripting: Intercept any Object-first message calls

I am writing my own non-ObjC framework around Cocoa Scripting (think of writing a scriptable Mac app in C, C++ or Java, or in my case, Xojo). I like to be able to intercept any Object-first method invocation instead of having to add the actual…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
1
vote
1 answer

Making cocoa application scriptable

I am new to cocoa development Can any one please tell me how I can make my cocoa application scriptable. I want my application to perform certain actions,in response to scripts. I could not find easy guide or help.
Unicorn
  • 2,382
  • 6
  • 29
  • 42
0
votes
2 answers

Programmatically enable (or disable) AppleScript support for an application

I have an App Store app in which the free version is not scriptable, but the premium version is. AppleScript support is one of the key differences. I know the App Store reviewers are pushing more and more towards free + in-app-purchase, which will…
balthisar
  • 185
  • 1
  • 15
0
votes
1 answer

Evaluate a Cocoa Scripting object from NSAppleEventDescriptor

In my sdef, I have a command that accepts a parameter of type "Any". In the script, I pass the reference to a scriptable object: tell application "myApp" set theArg to first subItem of appElement -- appElement is an element of the app object …
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
0
votes
1 answer

Sketch Plugin Development: Export Symbol as SVG Text

I have a working example of exporting a selected symbol to an SVG string in Sketch 3. (Based on this code from Sketch's GitHub) The issue is the output is distorted and I'm unable to see the next logical step in troubleshooting. The Code // Get all…
Zachary Schuessler
  • 3,644
  • 2
  • 28
  • 43
0
votes
1 answer

Cocoa Scripting: Getting the index of a scriptable object in its container

Given a scriptable object's NSScriptObjectSpecifier, how do I tell the index of object(s) in their container? I cannot find any accessor method for that in the NSScriptObjectSpecifier or its subclasses. If the object is a NSIndexSpecifier, it's easy…
Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
0
votes
1 answer

Add scriptable property to Cocoa application derived from NSObject ?

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.
1
2