• 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: Get the window at a certain point
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Get the window at a certain point
      • From: "M. Uli Kusterer" <email@hidden>
References: 
 >Get the window at a certain point (From: Tim Conkling <email@hidden>)

  • Prev by Date: Re: Use of long long's in a Cocoa program?
  • Next by Date: Re: Advice for cross-platform equivalent of NSFileWrapper
  • Previous by thread: Get the window at a certain point
  • Next by thread: Re: Get the window at a certain point
  • Index(es):
    • Date
    • Thread