• 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
How to run modal for all windows?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to run modal for all windows?


  • Subject: How to run modal for all windows?
  • From: James Howard <email@hidden>
  • Date: Fri, 18 Nov 2005 14:22:15 -0800

Hi all,

I have a callback that I do not want to return from until some user event has transpired (I want to stall the code that calls the callback for a while). This callback necessarily happens in the UI thread, so it isn't like I can just put a pthread_cond_wait or something in it and then signal it from another thread. What I want to do is just start up another event loop and read and dispatch events from there until my condition occurs, and then at that point I'll stop and return back out of the callback and go back to the base event loop for the application.

For those that prefer code, I want to have something like this:

void callbackFunction() {
// read and dispatch events until some particular event occurs, and return only then.
while([NSApp runModalSession: someModalSessionForALLWindows] != NSRunStoppedResponse]) {
// wait a small amount of time or something
}
}


But, unfortunately, there is no way to get an NSModalSession for all windows. They're always tied to one particular window.

Here are a couple of workarounds I've considered, and their relative pros and cons:
1) Just run modal for one window
+ NSApplication already has a method for this
- Ideally I want users to be able to interact with multiple windows until such time as the event that frees the callback function occurs


2) Run modal sessions for all the windows back to back:
pseudocode example:
while event has not occurred
	foreach window in the application
		run modal for window once through its event loop

+ Handles all windows
- Events will almost surely get dropped. I haven't tried this, but I don't think it will work for precisely that reason.


3) Start up a modal session, then get ahold of the current runloop and change it back into a regular one from a modal one.
- I have no idea if this would even work. I guess I'll go try it, but I suspect the outcome won't be good.


4) Cook up some hare brained user level threads solution
- Ugh.

Anyway, I feel like this problem shouldn't be that hard, but it has me stumped.

- James

_______________________________________________
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: "Proper" way to deal with "new" and "deprecated" methods when targeting more then one version
  • Next by Date: Distributed Objects - which frameworks?
  • Previous by thread: "Proper" way to deal with "new" and "deprecated" methods when targeting more then one version
  • Next by thread: RE: How to run modal for all windows?
  • Index(es):
    • Date
    • Thread