ScriptingBridge Commands
ScriptingBridge Commands
- Subject: ScriptingBridge Commands
- From: John Nairn <email@hidden>
- Date: Tue, 4 May 2010 13:35:25 -0700
I have been using ScriptingBridge to script my AppleScriptable Cocoa
app using Python and Ruby. Today I noticed that commands defined on
the main application do not work with error message that the
application has no such attribute. I checked the header file created
by the ScriptingBridge and see that all commands are defined in a
generic GEDitCOM_IIItem that is subclass of SBObject:
// A scriptable object.
@interface GEDitCOM_IIItem : SBObject
@property (copy) NSDictionary *properties; // All of the object's
properties.
- (void) closeSaving:(GEDitCOM_IISavo)saving savingIn:(NSURL *)
savingIn; // Close an object.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)
withProperties; // Copy object(s) and put the copies at a new location.
(The rest of the commands including all my defined commands)
@end
While all my scripting objects subclass this GEDitCOM_IIItem, the main
application object does not. It is defined as subclass of SBApplication:
// An application's top level scripting object.
@interface GEDitCOM_IIApplication : SBApplication
+ (GEDitCOM_IIApplication *) application;
- (SBElementArray *) documents;
- (SBElementArray *) windows;
@property (readonly) BOOL frontmost; // Is this the frontmost
(active) application?
@property (copy, readonly) NSString *name; // The name of the
application.
@property (copy, readonly) NSString *version; // The version of the
application.
- (GEDitCOM_IIDocument *) open:(NSURL *)x; // Open an object.
- (void) print:(NSURL *)x printDialog:(BOOL)printDialog withProperties:
(GEDitCOM_IIPrintSettings *)withProperties; // Print an object.
- (void) quitSaving:(GEDitCOM_IISavo)saving; // Quit an application.
@end
The net result seems to be that commands defined at the application
level will not work. In other words, the AppleScript
tell application "GEDitCOM II"
set someResult to myCommand argument arg1
end tell
which in python would be
gedit = SBApplication.applicationWithBundleIdentifier_
("com.geditcom.GEDitCOMII")
someResult=gedit.myCommandArgument_(arg1)
should both work. For me the AppleScript method works (verifying my
command is defined correctly), but the python one does not work. Is
this a bug in the ScriptingBridge framework?
------------
John Nairn
http://www.geditcom.com
Genealogy Software for the Mac
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden