Re: Get the window at a certain point
Re: Get the window at a certain point
- Subject: Re: Get the window at a certain point
- From: Ryan Stevens <email@hidden>
- Date: Fri, 12 Nov 2004 08:45:58 -0800
On Nov 12, 2004, at 12:06 AM, Tim Conkling wrote:
I need to find which window of my app (if any) is directly underneath
a certain pixel on the screen. In Carbon-land this is easily achieved
with FindWindow, but I'm not sure how to accomplish it in Cocoa.
// Std. Written in Mail..
@interface NSWindow (FindWindow)
- (id)windowAtPoint:(NSPoint)aPoint;
@end
@implementation NSWindow (FindWindow)
- (id)windowAtPoint:(NSPoint)aPoint
{
NSArray *winList = [NSApp windows];
NSEnumerator *enumerator = [winList objectEnumerator];
id object=nil;
while (object = [enumerator nextObject]) {
NSRect winFrame = [object frame];
if (NSPointInRect(aPoint, winFrame)) return object;
}
return nil;
}
@end
_______________________________________________
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