[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to end a modal run loop?

From: Andreas Heppel
Subject: Re: How to end a modal run loop?
Date: Tue, 10 Sep 2002 11:54:19 +0200

it seems like I finally found a solution to my problem below. Now, I just enter 
a loop running as long as my external task is running and within fetching all 
events and dispatching them.

while ([task isRunning])
NSEvent *event = [NSApp
           nextEventMatchingMask: 0xffffffff
           untilDate:[NSDate dateWithTimeIntervalSinceNow: 0.2]
if (event)
[NSApp sendEvent: event];

Seems to work so far, though my application is no longer modal and the user can 
wildly click around. But I think this can be coped with much easier ;-)


On 2002-09-10 11:12:13 +0200 Andreas Heppel <address@hidden> wrote:

Hi all,
I have the following problem.
My application starts an external task. The tasks progress is to be displayed 
in a small window unsing a progress indicator. The indicator is updated using a 
timer refiring until the external task is finished. Afterwards my application 
is allowed to proceed further. So far so good. This is not really hard to 
My problem now is that the window has a couple of buttons. If I use [NSTask 
waitUntilExit], the timer fires and the progress indicator proceeds but the 
buttons in my window don't respond to mouse clicks. Thus, I start a modal 
session for this window using [NSApplication runModalForWindow:]. This works 
fine up to the point where the external task finishes. My timer sees this and 
stops the modal loop [NSApplication stopModal]. Unfortunately, the procedure 
having started the loop (and is still waiting for it to finish) does not 
recognize this until the mouse pointer is moved into my application, i.e. the 
application receives an event. This behaviour is absolutely inacceptable for my 
application because it needs to proceed without any user interaction inbetween 
(even if it is just moving the mouse pointer into the window).
If I have understood the NSApplication/NSRunLoop/GSDisplayServer code 
correctly, the application waits in [NSApplication runModalSession:] 
indefinitely for an event. Only after an event occurred, it realizes that the 
modal session has finished. Why is this so?
Is there any other way to keep my progress window responsive to eventual mouse 
clicks on the one hand and on the other hand have my application detect that 
the modal session has ended (after stopModal).


Discuss-gnustep mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]