• 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 do modal mouse tracking loop efficiently?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to do modal mouse tracking loop efficiently?


  • Subject: How to do modal mouse tracking loop efficiently?
  • From: Håkan Waara <email@hidden>
  • Date: Fri, 9 Jun 2006 01:18:15 +0200

Hi all,

I'm overriding trackMouse: in my NSButtonCell subclass, in order to provide custom tracking behavior.

Right now, I'm doing something like this:

// we're tracking the middle mouse button in this case
unsigned eventMask = (NSOtherMouseUpMask | NSOtherMouseDraggedMask);

while (1) {
// wait for the next event we are interested in
NSEvent* event = [NSApp nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];


// highlight the button cell if the cursor is inside the cell, and break on mouse up
}


Obviously, other events are queued up and it creates a lot of weird side-effects when all those events are dispatched *after* the whole mouse tracking.

Does anyone know of a better way to implement trackMouse: such that it is easier on the system, and perhaps by not blocking all other events on the same thread?

TIA,
/Håkan _______________________________________________
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: Re: Changing fonts without font menu?
  • Next by Date: Re: Distributed Objects, copying thereof
  • Previous by thread: Re: Bindings and a dictionary
  • Next by thread: NSCFDictionary custom callbacks (Or: I Was Wrong)
  • Index(es):
    • Date
    • Thread