How to do modal mouse tracking loop efficiently?
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