• 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
Getting mouse clicks when the main loop is busy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting mouse clicks when the main loop is busy


  • Subject: Getting mouse clicks when the main loop is busy
  • From: Graham Cox <email@hidden>
  • Date: Fri, 08 Nov 2013 18:16:48 +0100

Hi all,

I have the need to display a progress dialog while I open a huge file. The file may be opened on the main thread, and the progress notifications are sent synchronously.

Since the main thread is blocked doing the file opening work, I force the window to redraw by directly calling its -displayIfNeeded method, and that indeed works as expected. However, I would like to be able to click a ‘Cancel’ button in this window. So, I thought I could just allow normal mouse click events to be handled by calling the -runUntilDate: method of the main runloop. By using a date value of -distantPast, this method shouldn’t sleep and so this occasional tickle of the runloop doesn’t slow down the file opening.

Unfortunately, it doesn’t work: the mouse clicks are not received and/or processed (I’m not sure which). The Cancel button is just an ordinary button, and if the dialog is displayed as a window without doing any work, I can click the button as normal.

I’ve also tried running the runloop as above, then immediately trying to handle any events for the window directly (which seems unnecessary, but I tried it anyway). That doesn’t help.

What’s the proper way to do this? I *can* open the file on another thread and let the main thread run normally, and that’s fine, but I do need a solution that works for when the file is opened on the main thread.

—Graham



_______________________________________________

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: Getting mouse clicks when the main loop is busy
      • From: Fritz Anderson <email@hidden>
    • Re: Getting mouse clicks when the main loop is busy
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: NSCustomImageRep and NSImage setSize
  • Next by Date: Re: Getting mouse clicks when the main loop is busy
  • Previous by thread: Re: How to tell if a file is writable in sandboxed mode?
  • Next by thread: Re: Getting mouse clicks when the main loop is busy
  • Index(es):
    • Date
    • Thread