Re: How can I display a dialog in one non-main thread?
Re: How can I display a dialog in one non-main thread?
- Subject: Re: How can I display a dialog in one non-main thread?
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 20 Sep 2003 09:56:24 -0700
Dan,
This is the wrong list for this question. For questions about Cocoa methods,
write the cocoa developers mailing list. For questions about AppleScript
Studio, write the applescript studio mailing list.
That said, I've had a bit of experience with this. Here's what I see:
1. You haven't closed the quotes here:
@"display dialog \"Hello Thread1\"
Should be;
@"display dialog \"Hello Thread1\""
2. I have successfully used just such a construction in a Cocoa class to
send an AppleScript to an external application, and it works fine. But when
I tried your method in a simple class I got nothing at all - no display
dialog, and no NS error - just nothing. So I suspect that you can't send an
Apple Event to your own application (i.e. The 'current application' which is
the default when no application is targeted by the AppleScript) unless
perhaps you have made your application scriptable. I would guess that if you
implement script ability for your application - as perhaps you have if
you're getting a blank display dialog with the faulty line above - it might
work with the fixed line. (Perhaps if you had provided something for your
errors dictionary you would have got something useful back.)
--
Paul Berkowitz
>
From: "Dan" <email@hidden>
>
Date: Sat, 20 Sep 2003 10:56:19 +0800
>
To: <email@hidden>
>
Subject: How can I display a dialog in one non-main thread?
>
>
Dear All:
>
I have some problem about AppleScript , cocoa Multithread.
>
>
In Main Thread, I create a new thread:
>
>
....
>
[NSThread detachNewThreadSelector:@selector(thread1:) toTarget:self
>
withObject]
>
....
>
>
In thread1, I only display a dialog:
>
>
- (void) thread1
>
{
>
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>
>
NSString *script = [[NSString alloc] initWithFormat:
>
@"display dialog \"Hello Thread1\"];
>
NSAppleScript *appleScript = [[NSAppleScript alloc]
>
initWithSource:script];
>
>
NSMutableDictionary *errors = [NSMutableDictionary dictionary];
>
>
[appleScript executeAndReturnError:&errors];
>
[appleScript release];
>
[script release];
>
>
>
[pool release];
>
}
>
>
>
But there only show a blank dialog, there is no any text and button on dialog.
>
How can I do that? Who can help me?
>
>
Thanks a lot!
>
>
Best Regards
>
Dan
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.