зеркало из https://github.com/electron/electron.git
feat: support `mouse-move` event of Tray API on Windows (#19265)
* add Tray.mouse-move on win * change docs
This commit is contained in:
Родитель
9711fc895e
Коммит
2467350180
|
@ -161,7 +161,7 @@ Returns:
|
|||
|
||||
Emitted when the mouse exits the tray icon.
|
||||
|
||||
#### Event: 'mouse-move' _macOS_
|
||||
#### Event: 'mouse-move' _macOS_ _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
|
|
|
@ -65,6 +65,13 @@ void NotifyIcon::HandleClickEvent(int modifiers,
|
|||
}
|
||||
}
|
||||
|
||||
void NotifyIcon::HandleMouseMoveEvent(int modifiers) {
|
||||
gfx::Point cursorPos = display::Screen::GetScreen()->GetCursorScreenPoint();
|
||||
// Omit event fired when tray icon is created but cursor is outside of it.
|
||||
if (GetBounds().Contains(cursorPos))
|
||||
NotifyMouseMoved(cursorPos, modifiers);
|
||||
}
|
||||
|
||||
void NotifyIcon::ResetIcon() {
|
||||
NOTIFYICONDATA icon_data;
|
||||
InitIconData(&icon_data);
|
||||
|
|
|
@ -44,6 +44,9 @@ class NotifyIcon : public TrayIcon {
|
|||
bool left_button_click,
|
||||
bool double_button_click);
|
||||
|
||||
// Handles a mouse move event from the user.
|
||||
void HandleMouseMoveEvent(int modifiers);
|
||||
|
||||
// Re-creates the status tray icon now after the taskbar has been created.
|
||||
void ResetIcon();
|
||||
|
||||
|
|
|
@ -170,6 +170,10 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
|
|||
(lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK),
|
||||
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK));
|
||||
return TRUE;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
win_icon->HandleMouseMoveEvent(GetKeyboardModifers());
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return ::DefWindowProc(hwnd, message, wparam, lparam);
|
||||
|
|
Загрузка…
Ссылка в новой задаче