feat: add middle click event to tray (#39926)
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
480f48b2fc
commit
689d1b76de
9 changed files with 33 additions and 3 deletions
|
@ -73,7 +73,8 @@ NotifyIcon::~NotifyIcon() {
|
|||
|
||||
void NotifyIcon::HandleClickEvent(int modifiers,
|
||||
bool left_mouse_click,
|
||||
bool double_button_click) {
|
||||
bool double_button_click,
|
||||
bool middle_button_click) {
|
||||
gfx::Rect bounds = GetBounds();
|
||||
|
||||
if (left_mouse_click) {
|
||||
|
@ -84,6 +85,8 @@ void NotifyIcon::HandleClickEvent(int modifiers,
|
|||
display::Screen::GetScreen()->GetCursorScreenPoint(),
|
||||
modifiers);
|
||||
return;
|
||||
} else if (middle_button_click) { // single middle click
|
||||
NotifyMiddleClicked(bounds, modifiers);
|
||||
} else if (!double_button_click) { // single right click
|
||||
if (menu_model_)
|
||||
PopUpContextMenu(gfx::Point(), menu_model_->GetWeakPtr());
|
||||
|
|
|
@ -45,7 +45,8 @@ class NotifyIcon : public TrayIcon {
|
|||
// otherwise displays the context menu if there is one.
|
||||
void HandleClickEvent(int modifiers,
|
||||
bool left_button_click,
|
||||
bool double_button_click);
|
||||
bool double_button_click,
|
||||
bool middle_button_click);
|
||||
|
||||
// Handles a mouse move event from the user.
|
||||
void HandleMouseMoveEvent(int modifiers);
|
||||
|
|
|
@ -189,8 +189,10 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
|
|||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
case WM_CONTEXTMENU:
|
||||
// Walk our icons, find which one was clicked on, and invoke its
|
||||
// HandleClickEvent() method.
|
||||
|
@ -200,7 +202,8 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
|
|||
&NotifyIcon::HandleClickEvent, win_icon_weak,
|
||||
GetKeyboardModifiers(),
|
||||
(lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK),
|
||||
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK)));
|
||||
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK),
|
||||
(lparam == WM_MBUTTONDOWN || lparam == WM_MBUTTONDBLCLK)));
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue