• 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
Re: Confused with modal sessions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confused with modal sessions


  • Subject: Re: Confused with modal sessions
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 3 May 2006 18:55:44 +0100

Ah brilliant. I hadn't really understood the way in which the modal session works then.

Mike.

On 3 May 2006, at 16:28PM0, Keary Suska wrote:

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:
40gmail.com


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Re: Confused with modal sessions (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: Keyboard short-cuts edit field
  • Next by Date: NSString drawInRect:withAttributes: clips descenders
  • Previous by thread: Re: Confused with modal sessions
  • Next by thread: Sub pixel line positioning for text drawing
  • Index(es):
    • Date
    • Thread