fix: emit click events with tray context menu (#24200)

This commit is contained in:
Shelley Vohr 2020-06-22 08:24:47 -07:00 committed by GitHub
parent 0629c6c2ea
commit 046a05944a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -130,23 +130,7 @@
[statusItem_ setMenu:[menuController_ menu]];
}
- (void)mouseDown:(NSEvent*)event {
trayIcon_->NotifyMouseDown(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
// Pass click to superclass to show menu. Custom mouseUp handler won't be
// invoked.
if (menuController_) {
[super mouseDown:event];
} else {
[[statusItem_ button] highlight:YES];
}
}
- (void)mouseUp:(NSEvent*)event {
[[statusItem_ button] highlight:NO];
- (void)handleClickNotifications:(NSEvent*)event {
trayIcon_->NotifyMouseUp(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
@ -170,6 +154,27 @@
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)mouseDown:(NSEvent*)event {
trayIcon_->NotifyMouseDown(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
// Pass click to superclass to show menu. Custom mouseUp handler won't be
// invoked.
if (menuController_) {
[self handleClickNotifications:event];
[super mouseDown:event];
} else {
[[statusItem_ button] highlight:YES];
}
}
- (void)mouseUp:(NSEvent*)event {
[[statusItem_ button] highlight:NO];
[self handleClickNotifications:event];
}
- (void)popUpContextMenu:(electron::ElectronMenuModel*)menu_model {
// Make sure events can be pumped while the menu is up.
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;