Re: Output from NSTask and modal window
Re: Output from NSTask and modal window
- Subject: Re: Output from NSTask and modal window
- From: Christophe Dore <email@hidden>
- Date: Mon, 21 Jan 2002 15:26:26 +0100
doing a blocking stuff in
- (void)myService:(NSPasteboard *)pboard
userData:(NSString *)data
error:(NSString **)erro
is dangerous because you have a timeout on this.
I mean that if the user is not fast enough, the app from which the
service is called will ignore the result of the service.
Sven-S. Porst wrote:
what I meant is that when you call runModalSession, it puts the current
run loop in ModalPanelMode.
Thus, the runloop does not care any more for things that are only to be
watched in NSDefaultRunLoopMode.
I thought it would be a good idea to just make the run loop care for the
things I think it should care for - but the run loop business doesn't
make enough sense to me to figure out how to do this.
If you want to simulate a modal panel without changing the current mode,
you can :
- set the level of the panel to NSModalPanelWindowLevel
- make it key and order front,
- filter the NSEvents in sendEvent: method of NSApp, to only deliver
those events that are about your panel,
until you click one of those famous OK/CANCEL... buttons that would make
this pseudo modal mode stop.
This would somehow evade my initial reason to use a modal window, I
suppose. I would be perfectly happy to use a normal window, but as I am
doing this while running a service, I have something like
- (void)myService:(NSPasteboard *)pboard
userData:(NSString *)data
error:(NSString **)error
{
..
result = [NSApp runModalForWindow: ...];
..
}
and I suppose that I have to have the result ready by the time, my
function returns. So I don't think it is an option to so something like that.
Cheers
Sven