File: programming/cocoa/UKDockableView.zip/UKDockableWindow/NSApplicationWindowAtPoint.m


//
//  NSApplicationWindowAtPoint.m
//  UKDockableWindow
//
//  Created by Uli Kusterer on Wed Feb 04 2004.
//  Copyright (c) 2004 M. Uli Kusterer. All rights reserved.
//
 
#import "NSApplicationWindowAtPoint.h"
 
 
@implementation NSApplication (WindowAtPoint)
 
-(NSWindow*)	windowAtPoint: (NSPoint)pos ignoreWindow: (NSWindow*)ignorew
{
	NSArray*		winArray = [self windows];
	NSEnumerator*   enny = [winArray objectEnumerator];
	NSWindow*		theWin = nil;
	
	while( theWin = [enny nextObject] )
	{
		if( theWin == ignorew )		// Skip the window to ignore.
			continue;
		
		if( ![theWin isVisible] )   // Skip invisible windows.
			continue;
		
		if( NSPointInRect( pos, [theWin frame] ) )
			return theWin;
	}
	
	return nil;
}
 
@end

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.