mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: emit click events with tray context menu (#24235)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -130,27 +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];
|
||||
|
||||
trayIcon_->NotifyMouseUp(
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
|
||||
- (void)handleClickNotifications:(NSEvent*)event {
|
||||
// If we are ignoring double click events, we should ignore the `clickCount`
|
||||
// value and immediately emit a click event.
|
||||
BOOL shouldBeHandledAsASingleClick =
|
||||
@@ -170,6 +150,31 @@
|
||||
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];
|
||||
|
||||
trayIcon_->NotifyMouseUp(
|
||||
gfx::ScreenPointFromNSPoint([event locationInWindow]),
|
||||
ui::EventFlagsFromModifiers([event modifierFlags]));
|
||||
|
||||
[self handleClickNotifications:event];
|
||||
}
|
||||
|
||||
- (void)popUpContextMenu:(electron::ElectronMenuModel*)menu_model {
|
||||
// Make sure events can be pumped while the menu is up.
|
||||
base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
|
||||
|
||||
Reference in New Issue
Block a user