Re: How to detect clicks outside of modal window?
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