Skip navigation.
 
mlHow to wait modally for a few seconds
FROM : Eyal Redler
DATE : Sun Dec 08 14:59:00 2002

Hi,

I need to display a window *modally* for a few seconds.
I tried setting up a timer but I'm having trouble "waiting".
Writing a while loop like this:
while (!stopRunning)
{
}
Where the timer is setting stopRunning to YES. Didn't work (I know,
it's stupid...)

I tried setting up a run loop like this (Apple example)
BOOL endRunLoop = NO;
BOOL isRunning;
do {
    isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
                beforeDate:[NSDate distantFuture]] );
} while ( isRunning && !endRunLoop);
Where the timer is setting endRunLoop to true but the timer is never
getting called unless I move the mouse, click etc.
If I set beforeDate to [NSDate  dateWithTimeIntervalSinceNow:0.1] I get
the right timing but the window is still modeless

Last thing I tried:
    [NSEvent startPeriodicEventsAfterDelay:10 withPeriod:0.01];
    while (YES)
    {
        anEvent = [window nextEventMatchingMask: NSPeriodicMask];
        if ([anEvent type]==NSPeriodic)
            break;
    }

    [NSEvent stopPeriodicEvents];
Works fine, but isn't modal...

So, what's the best way just to wait... Surely there's a simpler way...

Thanks,

Eyal Redler
=====================================
RedleX - Software for what's left of us
www.redlers.com


Related mailsAuthorDate
mlHow to wait modally for a few seconds Eyal Redler Dec 8, 14:59
mlRE: How to wait modally for a few seconds Tobias Peciva Dec 8, 15:30
mlRe: How to wait modally for a few seconds Eyal Redler Dec 8, 15:40
mlRe: How to wait modally for a few seconds Scott Anguish Dec 8, 17:34
mlRe: How to wait modally for a few seconds Eyal Redler Dec 8, 17:46
mlRe: How to wait modally for a few seconds David Stevenson Dec 8, 17:51
mlRE: How to wait modally for a few seconds Tobias Peciva Dec 8, 18:06
mlRe: How to wait modally for a few seconds Scott Anguish Dec 8, 23:03