Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: ui/message_center/cocoa/tray_controller.mm

Issue 16098005: [Mac][MC] Close the tray window when the user clicks outside it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/cocoa/tray_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/cocoa/tray_controller.mm
diff --git a/ui/message_center/cocoa/tray_controller.mm b/ui/message_center/cocoa/tray_controller.mm
index 6b78d657231254c3835bb2226b740c000c4130be..abe07e3aff0934d4d5b35adebde4dc60fa151c3c 100644
--- a/ui/message_center/cocoa/tray_controller.mm
+++ b/ui/message_center/cocoa/tray_controller.mm
@@ -43,10 +43,26 @@
NSView* contentView = [viewController_ view];
[window setFrame:[contentView frame] display:NO];
[window setContentView:contentView];
+
+ // The global event monitor will close the tray in response to events
+ // delivered to other applications, and -windowDidResignKey: will catch
+ // events within the application.
+ clickEventMonitor_ =
+ [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask |
+ NSRightMouseDownMask |
+ NSOtherMouseDownMask
+ handler:^(NSEvent* event) {
+ tray_->HideMessageCenterBubble();
+ }];
}
return self;
}
+- (void)dealloc {
+ [NSEvent removeMonitor:clickEventMonitor_];
+ [super dealloc];
+}
+
- (void)showTrayAt:(NSPoint)point {
NSRect frame = [[viewController_ view] frame];
frame.origin.x = point.x;
« no previous file with comments | « ui/message_center/cocoa/tray_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698