• 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 interrupt a long loop with command-period?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to interrupt a long loop with command-period?


  • Subject: How to interrupt a long loop with command-period?
  • From: Duncan Champney <email@hidden>
  • Date: Sat, 29 Mar 2008 20:45:38 -0400

My app can create 3D views of the fractal images it creates.

It has an option to save very large versions of these 3D views to disk as JPEGs or TIFFs. I generate the images as tiles, then assemble them and save the result to disk. For very large images this can take tens of seconds.

I have a save panel that I display as a sheet on my 3D view, and I'm showing a progress bar on the save panel as I build the image for saving. My code has to call [progress_bar display] explicitly, since I don't visit the event loop while I'm generating my image.

I'd like to be able to have the user press command-period/escape and quit the save in the middle.

I thought I could check for key down events with a call like this:

   theEvent =              [[self window] nextEventMatchingMask:(NSKeyDownMask)];

But when I issue that call, everything comes to a halt until the user presses a key.

I really want a "check the event queue for keyboard events" call that would let me pick command period or escape key events out of the applications event queue.

I don't want to re-factor my code to return to the event loop if I can help it, both because it would be a fair amount of work, and because I'm using the OpenGL back buffer for my window to do my tiled rendering, and if the user makes changes to the window it would mess up my off-screen rendering. If I do have to re-factor my code to service the event loop I'll have to tear down the save panel sheet only to draw another save progress sheet in it's place, both as a place to show a progress bar, and to keep the user from messing up the save that's in progress. At least if I did that I could put a cancel button on it and be able to respond when the user clicks it.



Duncan C

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to interrupt a long loop with command-period?
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: weak linking
  • Next by Date: NSManagedObject Copy and Paste
  • Previous by thread: Re: weak linking
  • Next by thread: Re: How to interrupt a long loop with command-period?
  • Index(es):
    • Date
    • Thread