@@ -130,6 +130,26 @@ - (void)setMenuController:(ElectronMenuController*)menu {
130
130
[statusItem_ setMenu: [menuController_ menu ]];
131
131
}
132
132
133
+ - (void )handleClickNotifications : (NSEvent *)event {
134
+ // If we are ignoring double click events, we should ignore the `clickCount`
135
+ // value and immediately emit a click event.
136
+ BOOL shouldBeHandledAsASingleClick =
137
+ (event.clickCount == 1 ) || ignoreDoubleClickEvents_;
138
+ if (shouldBeHandledAsASingleClick)
139
+ trayIcon_->NotifyClicked (
140
+ gfx::ScreenRectFromNSRect (event.window .frame ),
141
+ gfx::ScreenPointFromNSPoint ([event locationInWindow ]),
142
+ ui::EventFlagsFromModifiers ([event modifierFlags ]));
143
+
144
+ // Double click event.
145
+ BOOL shouldBeHandledAsADoubleClick =
146
+ (event.clickCount == 2 ) && !ignoreDoubleClickEvents_;
147
+ if (shouldBeHandledAsADoubleClick)
148
+ trayIcon_->NotifyDoubleClicked (
149
+ gfx::ScreenRectFromNSRect (event.window .frame ),
150
+ ui::EventFlagsFromModifiers ([event modifierFlags ]));
151
+ }
152
+
133
153
- (void )mouseDown : (NSEvent *)event {
134
154
trayIcon_->NotifyMouseDown (
135
155
gfx::ScreenPointFromNSPoint ([event locationInWindow ]),
@@ -138,6 +158,7 @@ - (void)mouseDown:(NSEvent*)event {
138
158
// Pass click to superclass to show menu. Custom mouseUp handler won't be
139
159
// invoked.
140
160
if (menuController_) {
161
+ [self handleClickNotifications: event];
141
162
[super mouseDown: event];
142
163
} else {
143
164
[[statusItem_ button ] highlight: YES ];
@@ -151,23 +172,7 @@ - (void)mouseUp:(NSEvent*)event {
151
172
gfx::ScreenPointFromNSPoint ([event locationInWindow ]),
152
173
ui::EventFlagsFromModifiers ([event modifierFlags ]));
153
174
154
- // If we are ignoring double click events, we should ignore the `clickCount`
155
- // value and immediately emit a click event.
156
- BOOL shouldBeHandledAsASingleClick =
157
- (event.clickCount == 1 ) || ignoreDoubleClickEvents_;
158
- if (shouldBeHandledAsASingleClick)
159
- trayIcon_->NotifyClicked (
160
- gfx::ScreenRectFromNSRect (event.window .frame ),
161
- gfx::ScreenPointFromNSPoint ([event locationInWindow ]),
162
- ui::EventFlagsFromModifiers ([event modifierFlags ]));
163
-
164
- // Double click event.
165
- BOOL shouldBeHandledAsADoubleClick =
166
- (event.clickCount == 2 ) && !ignoreDoubleClickEvents_;
167
- if (shouldBeHandledAsADoubleClick)
168
- trayIcon_->NotifyDoubleClicked (
169
- gfx::ScreenRectFromNSRect (event.window .frame ),
170
- ui::EventFlagsFromModifiers ([event modifierFlags ]));
175
+ [self handleClickNotifications: event];
171
176
}
172
177
173
178
- (void )popUpContextMenu : (electron::ElectronMenuModel*)menu_model {
0 commit comments