• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSApp runModalSession: problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSApp runModalSession: problem


  • Subject: NSApp runModalSession: problem
  • From: Mark Alldritt <email@hidden>
  • Date: Sun, 11 Sep 2005 08:40:14 -0700

Hi All,

I have a modal progress dialog that I present while waiting for a library to
finish a long running operation.  The library periodically calls an idle
proc.  In my idle proc, I use NSApp runModalSession: to run the progress
dialog.

The problem is that if I move the dialog window by dragging the window title
bar, controls within the progress dialog no longer respond to mouse clicks.
Specifically, I can no longer click in a Cancel button.  Interestingly, the
button continues to respond to keyboard events (Command-.).

The dialog window is an NSPanel loaded from a nib file.  This happens on
both Panther and Tiger systems.  Does anyone have any ideas what I might be
doing wrong?

Here's the code that displays and runs the progress dialog:

- (void) showProgress
{
    if (!mVisible)
    {
        mInterrupted = NO;

        if (!mStartDate)
            mStartDate = [[NSDate alloc] init];
        else if (mStartDate && [[NSDate date]
timeIntervalSinceDate:mStartDate] >= kShowInterval)
        {
            [mStartDate release];
               mStartDate = nil;

            [mInterrupt setEnabled:YES];
            [mProgress startAnimation:self];
            mModalSession = [NSApp beginModalSessionForWindow:mWindow];
            [mWindow makeKeyAndOrderFront:self];
            mVisible = YES;
        }
    }
}

- (void) runProgress
{
    if (mVisible)
    {
        if (!mLastRun || [mLastRun timeIntervalSinceNow] < -kRunInterval)
        {
            int r = [NSApp runModalSession:mModalSession];
            if (r != NSRunContinuesResponse)
            {
#ifdef DEBUG
                NSLog(@"progress: %d", r);
#endif
            }
            [mLastRun release];
            mLastRun = [[NSDate date] retain];
        }
    }
}

- (void) hideProgress
{
    if (mVisible)
    {
        [mProgress stopAnimation:self];
        [NSApp endModalSession:mModalSession];
        [mWindow orderOut:self];
        mVisible = NO;
    }

    [mLastRun release];
    mLastRun = nil;

    [mStartDate release];
    mStartDate = nil;
}

Cheers
-Mark

------------------------------------------------------------------------
Mark Alldritt                      Late Night Software Ltd.
Phone: 250-380-1725                Script Debugger 3.0 - AppleScript IDE
WEB:  http://www.latenightsw.com/  FaceSpan 4.2 - AppleScript RAD
                                   Affrus 1.0 - Perl Debugging


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSScanner isAtEnd
  • Next by Date: NSApp runModalSession: problem
  • Previous by thread: Popups in table views Was: How to bind this situation?
  • Next by thread: NSApp runModalSession: problem
  • Index(es):
    • Date
    • Thread