• 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: How to detect clicks outside of modal window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect clicks outside of modal window?


  • Subject: Re: How to detect clicks outside of modal window?
  • From: David Riggle <email@hidden>
  • Date: Fri, 04 Nov 2011 15:33:55 -0700

Subclass NSApplication and override this method:

- (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag
{
	NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:deqFlag];
	NSEventType type = [event type];	// 0 if event is nil
	if (type == NSLeftMouseDown || type == NSRightMouseDown) {
		if (m_popoverModalWindow != nil && [event window] != m_popoverModalWindow) {
			[self stopModalWithCode:NSCancelButton];
			event = nil;
		}
	}
	return event;
}

Then add this method, which you call instead of -runModalForWindow:

- (NSInteger)runPopoverModalForWindow:(NSWindow *)theWindow
{
	m_popoverModalWindow = theWindow;
	NSInteger result = [super runModalForWindow:theWindow];
	m_popoverModalWindow = nil;
	return result;
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Core Data loading faulted object?
  • Next by Date: Re: [Q] loadView doesn't return?
  • Previous by thread: Re: How to detect clicks outside of modal window?
  • Next by thread: NSTreeController won't initWithCoder on Leopard
  • Index(es):
    • Date
    • Thread