• 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: NSMenu and RunLoop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenu and RunLoop?


  • Subject: Re: NSMenu and RunLoop?
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 1 Jun 2004 18:36:57 -0700

Hello...

You probably want to take a look at the documentation for NSRunLoop. There's also a CoreFoundation conceptual topic related to CFRunLoop that has info about NSRunLoop as well.

Specifically, you need to register your timer for the event tracking mode in addition to the default run loop mode.

So, when you register your timer it would look something like this:

NSTimer *importantTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(doSomethingImportant:) userInfo:nil repeats:TRUE];

[[NSRunLoop currentRunLoop] addTimer:importantTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:importantTimer forMode:NSEventTrackingRunLoopMode];

In addition to menu tracking, this also applies to getting timers to fire during drag and drop operations, mouse dragging, and other special event tracking loops.


Make sure you don't do too much heavy processing when the timer fires, or you could affect the "feel" of the menu tracking or other events, although if it's not causing problems when it is running normally during the default run loop mode it should probably be okay (but keep in mind that when the run loop is running in event tracking mode, generally event processing is happening at a higher rate than normal).

Hope that helps,

Louis


Hi! I sure hope this is easy for someone.

I have an application that has NSTimers going off for processing. I just noticed that when a NSMenu is clicked on (showing the available NSMenuItems underneath it), the application halts. What's the easiest way for me to get it so that the NSMenu's don't stop/halt my applicaiton runLoop?

What was interesting is that I could click on a NSMenu and it puts it in a state where now I can move over the other Menu's and they will pop down to see them, this is cool; but my app is halted?

Thanks,
Pete Gordon
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSMenu and RunLoop? (From: Pete Gordon <email@hidden>)

  • Prev by Date: Re: incompatible pointer type warnings
  • Next by Date: Re: Getting filename of just opened document...
  • Previous by thread: NSMenu and RunLoop?
  • Next by thread: NSObjectController HELP
  • Index(es):
    • Date
    • Thread