8000 fix: emit click events with tray context menu by codebytere · Pull Request #24239 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: emit click events with tray context menu #24239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions shell/browser/ui/tray_icon_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,7 @@ - (void)setMenuController:(ElectronMenuController*)menu {
[statusItem_ setMenu:[menuController_ menu]];
}

- (void)mouseDown:(NSEvent*)event {
// 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 {
// If we are ignoring double click events, we should ignore the `clickCount`
// value and immediately emit a click event.
BOOL shouldBeHandledAsASingleClick =
Expand All @@ -162,6 +150,23 @@ - (void)mouseUp:(NSEvent*)event {
ui::EventFlagsFromModifiers([event modifierFlags]));
}

- (void)mouseDown:(NSEvent*)event {
// 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;
Expand Down
0