Normally, I'd package this more than just a slug of code, but this is too cool to delay and delay, editing and whatnot.
In the Finder, when you're dragging files from one window to another, after a while, the dragged-to window comes to the top, so that you can better figure out where to put it. This happens even if the Finder isn't the foreground app. This would be cool if other apps did this, as it's quite useful. And spiffy.
Cocoa has some very strange properties that others have commented on. First, it's not something you can simply read and remember. It's something you guess and reference, but that's a good thing. Second, if it's getting difficult, you're probably doing it wrong. Third, it's eerily easy to do difficult things, most of the time.
So, copying this behavior would be tough, requiring timers and extra events and such, right?
Given that this is the delegate for a window, which is called owningWindow, and you've also linked to Carbon (C'mon, all the cool kids mix and match!)
- (IBAction) stealTheShow:(id) sender;
{
[owningWindow orderFrontRegardless];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
[self performSelector:@selector(stealTheShow:) withObject:self afterDelay:GetDblTime()/60.0];
//SNIP...
}
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stealTheShow:) object:self];
//SNIP...
}
Note to self: make or find a quick app that you can drag formatted text to, and it outputs the appropriate HTML, to preserve all the funky xCode-y formatting without jumping through a few hoops.
For those of you who can't read code, the translation is: Do awesome thing with almost no effort. That is all.
