Re: Confused with modal sessions
Re: Confused with modal sessions
- Subject: Re: Confused with modal sessions
- From: Keary Suska <email@hidden>
- Date: Wed, 03 May 2006 09:28:51 -0600
on 5/3/06 8:21 AM, email@hidden purportedly said:
> I need some advice on what I am doing wrong trying to sort out a
> modal session.
>
> In my app, the user clicks a menu item to perform a task. Now this
> task takes a few seconds so I need to display a panel telling them
> that the task is in progress. I cannot spin this off into another
> thread since most of the work done is using NSAppleScript which
> explicitly says it should not be used in a thread.
>
> I had assumed that I could do [NSApp beginModalSessionForWindow:
> progressPanel], record the result and then do [NSApp
> runModalSession:] after. Once the processing is complete, I call
> [NSApp endModalSession:] with the modal session from before.
> However, this doesn't seem to work.
>
> The panel I'm bringing up with the beginModalSessionForWindow: method
> never goes away when I call endModalSession:
>
> What am I doing wrong? Should I even be using a modal session?
You can think of Modal sessions as simply a "mode" of the event loop such
that all events are only sent to a designated window, and therefore, no
other window can receive events. Although many methods for modal sessions
will display the designated window, they don't control the window like a
window controller. You can think of this window display behavior as a
convenience behavior of the methods, but it is still up to you to control
the behavior of the window.
Hence, endModalSession: doesn't dismiss a window, it just ends the modal
session. You will need to explicitly dismiss with NSWindow's orderOut:
method or the like.
runModalSession: essentially runs the event handling loop so your UI can
"handle" events and remain responsive.
Whether you want a modal session depends on the app behavior you want. If
you want to "block" the user from doing anything else while your process is
running, then a modal session is probably the best way to go.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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