Re: AppleScript little problem...
Re: AppleScript little problem...
- Subject: Re: AppleScript little problem...
- From: Nico <email@hidden>
- Date: Tue, 17 Dec 2002 06:11:58 +0100
Hi :)
Thanks for your answer !
I tried what you said and I've got a warning : "TypeInCommand does not
respond to 'directObject'.
?
Nico.
On mardi, dic 17, 2002, at 01:05 Europe/Paris, Greg Titus wrote:
>
Yeah, the direct parameter (in this case your string) is trying to be
>
evaluated as an object specifier to decide which object in your app
>
should get the handler called on it. That's the default behavior of
>
NSScriptCommand, and it is what you want to avoid.
>
>
What you want is your own subclass of NSScriptCommand that handles the
>
arguments directly by overriding -performDefaultImplementation:
>
>
@interface TypeInCommand : NSScriptCommand
>
{
>
}
>
@end
>
>
@implementation TypeInCommand
>
>
- (id)performDefaultImplementation;
>
{
>
NSString *string = [self directObject];
>
>
// do whatever you'd like with the string...
>
return nil;
>
}
>
@end
>
>
Change your .scriptSuite to specify the TypeInCommand as the
>
CommandClass for your command, and remove the SupportedCommands
>
section from your app object.
>
>
Hope this helps,
>
- Greg
>
On Monday, December 16, 2002, at 12:38 PM, Nico wrote:
>
>
> The problem is exactly that if I pass and argument, the
>
> handleSendCommand isn't called anymore ! :(
>
> I got a NSCannotCreateScriptCommandError from script editor :\
>
>
>
> Any thoughts ?
>
> Nico.
>
>
>
>
>
> On lundi, dic 16, 2002, at 20:44 Europe/Paris, Glenn Howes wrote:
>
>
>
>> In your handleSendCommand message, what do you get if you:
>
>>
>
>> -(id)handleSendCommand:(NSScriptCommand*)command
>
>> {
>
>> NSDictionary *args = [command evaluatedArguments];
>
>> NSLog([args description]);
>
>> }
>
>>
>
>> Also, shouldn't the NSObject in the following be an NSString?
>
>>> <key>AppleEventCode</key>
>
>>> <string>Strn</string>
>
>>> <key>Optional</key>
>
>>> <string>NO</string>
>
>>> <key>Type</key>
>
>>> <string>NSObject</string>
>
>>> </dict>
>
>>
>
>>
>
>>
>
>>
>
>> On Monday, December 16, 2002, at 01:20 PM, Nico wrote:
>
>>
>
>>> Hi !
>
>>>
>
>>> I partially made my app scriptable. Let me explain : you can type
>
>>> the
>
>>> "typein" command in script editor, but you can't add an argument.
>
>>> I've seen numerous examples, but still no luck.
>
>>>
>
>>> Here are the .scriptSuite, .scriptTerminology and the NSApplication
>
>>> category i use.
>
>>> Can you tell me if it's possible just to pass an argument so that
>
>>> the
>
>>> user can use
>
>>> tell application "MyApp" too typein "boo"
>
>>>
>
>>> Any help is *very* appreciated :-)
>
>>> Thanks in advance.
>
>>> Nico
>
>>> ---
>
>>>
>
>>>
>
>>>
>
>>>
>
>>>
>
>>> .scriptSuite
>
>>> <plist version="1.0">
>
>>> <dict>
>
>>> <key>AppleEventCode</key>
>
>>> <string>AKWA</string>
>
>>> <key>Classes</key>
>
>>> <dict>
>
>>> <key>NSApplication</key>
>
>>> <dict>
>
>>> <key>AppleEventCode</key>
>
>>> <string>capp</string>
>
>>> <key>Superclass</key>
>
>>> <string>NSCoreSuite.NSApplication</string>
>
>>> <key>SupportedCommands</key>
>
>>> <dict>
>
>>> <key>TypeIn</key>
>
>>> <string>handleSendCommand:</string>
>
>>> </dict>
>
>>> <key>ToManyRelationships</key>
>
>>> <dict>
>
>>> <key>orderedDocuments</key>
>
>>> <dict>
>
>>> <key>AppleEventCode</key>
>
>>> <string>docu</string>
>
>>> <key>Type</key>
>
>>> <string>AKDocument</string>
>
>>> </dict>
>
>>> </dict>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>Commands</key>
>
>>> <dict>
>
>>> <key>TypeIn</key>
>
>>> <dict>
>
>>> <key>AppleEventClassCode</key>
>
>>> <string>AKWA</string>
>
>>> <key>AppleEventCode</key>
>
>>> <string>Rvrs</string>
>
>>> <key>Arguments</key>
>
>>> <dict>
>
>>> <key>text</key>
>
>>> <dict>
>
>>> <key>AppleEventCode</key>
>
>>> <string>Strn</string>
>
>>> <key>Optional</key>
>
>>> <string>NO</string>
>
>>> <key>Type</key>
>
>>> <string>NSObject</string>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>CommandClass</key>
>
>>> <string>NSScriptCommand</string>
>
>>> <key>ResultAppleEventCode</key>
>
>>> <string>Strn</string>
>
>>> <key>Type</key>
>
>>> <string>NSString</string>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>Name</key>
>
>>> <string>MyApp</string>
>
>>> <key>Synonyms</key>
>
>>> <dict>
>
>>> <key>tact</key>
>
>>> <string>NSTextSuite.NSTextStorage</string>
>
>>> </dict>
>
>>> </dict>
>
>>>
>
>>>
>
>>>
>
>>>
>
>>> .scriptTerminology
>
>>> <dict>
>
>>> <key>Classes</key>
>
>>> <dict>
>
>>> <key>NSApplication</key>
>
>>> <dict>
>
>>> <key>Description</key>
>
>>> <string>AkwaIRC's top level scripting object.</string>
>
>>> <key>Name</key>
>
>>> <string>application</string>
>
>>> <key>PluralName</key>
>
>>> <string>applications</string>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>Commands</key>
>
>>> <dict>
>
>>> <key>TypeIn</key>
>
>>> <dict>
>
>>> <key>Arguments</key>
>
>>> <dict>
>
>>> <key>text</key>
>
>>> <dict>
>
>>> <key>AppleEventCode</key>
>
>>> <string>Strn</string>
>
>>> <key>Type</key>
>
>>> <string>NSObject</string>
>
>>> <key>Description</key>
>
>>> <string>fuka string</string>
>
>>> <key>Name</key>
>
>>> <string>text</string>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>Description</key>
>
>>> <string>Send some text to the current window.</string>
>
>>> <key>Name</key>
>
>>> <string>typein</string>
>
>>> </dict>
>
>>> </dict>
>
>>> <key>Description</key>
>
>>> <string>AkwaIRC specific classes.</string>
>
>>> <key>Name</key>
>
>>> <string>AkwaIRC suite</string>
>
>>> <key>Synonyms</key>
>
>>> <dict>
>
>>> <key>tact</key>
>
>>> <dict>
>
>>> <key>Description</key>
>
>>> <string>The textual contents of a text area graphic.</string>
>
>>> <key>Name</key>
>
>>> <string>text contents</string>
>
>>> </dict>
>
>>> </dict>
>
>>> </dict>
>
>>>
>
>>>
>
>>>
>
>>>
>
>>> and the category :-)
>
>>> @interface NSApplication (AKScripting)
>
>>> - (id)handleSendCommand:(NSScriptCommand *)command;
>
>>> @end
>
>>>
>
>>> @implementation NSApplication(MyAppScripting)
>
>>> - (id)handleSendCommand:(NSScriptCommand *)command
>
>>> {
>
>>> // do some stuff
>
>>> }
>
>>> _______________________________________________
>
>>> cocoa-dev mailing list | email@hidden
>
>>> Help/Unsubscribe/Archives:
>
>>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>>> Do not post admin requests to the list. They will be ignored.
>
>> _______________________________________________
>
>> cocoa-dev mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>> Do not post admin requests to the list. They will be ignored.
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.