mirror of
https://github.com/electron/electron.git
synced 2026-01-10 07:58:08 -05:00
win: Implement double-clicked event
This commit is contained in:
@@ -63,7 +63,8 @@ NotifyIcon::~NotifyIcon() {
|
||||
}
|
||||
|
||||
void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
||||
bool left_mouse_click) {
|
||||
bool left_mouse_click,
|
||||
bool double_button_click) {
|
||||
NOTIFYICONIDENTIFIER icon_id;
|
||||
memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
|
||||
icon_id.uID = icon_id_;
|
||||
@@ -72,14 +73,16 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
||||
RECT rect = { 0 };
|
||||
Shell_NotifyIconGetRect(&icon_id, &rect);
|
||||
|
||||
// Pass to the observer if appropriate.
|
||||
if (left_mouse_click) {
|
||||
NotifyClicked(gfx::Rect(rect));
|
||||
if (double_button_click) // double left click
|
||||
NotifyDoubleClicked(gfx::Rect(rect));
|
||||
else // single left click
|
||||
NotifyClicked(gfx::Rect(rect));
|
||||
return;
|
||||
} else if (!double_button_click) { // single right click
|
||||
NotifyRightClicked(gfx::Rect(rect));
|
||||
PopContextMenu(cursor_pos);
|
||||
}
|
||||
|
||||
NotifyRightClicked(gfx::Rect(rect));
|
||||
PopContextMenu(cursor_pos);
|
||||
}
|
||||
|
||||
void NotifyIcon::ResetIcon() {
|
||||
|
||||
@@ -33,7 +33,9 @@ class NotifyIcon : public TrayIcon {
|
||||
// Handles a click event from the user - if |left_button_click| is true and
|
||||
// there is a registered observer, passes the click event to the observer,
|
||||
// otherwise displays the context menu if there is one.
|
||||
void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click);
|
||||
void HandleClickEvent(const gfx::Point& cursor_pos,
|
||||
bool left_button_click,
|
||||
bool double_button_click);
|
||||
|
||||
// Re-creates the status tray icon now after the taskbar has been created.
|
||||
void ResetIcon();
|
||||
|
||||
@@ -146,12 +146,17 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_CONTEXTMENU:
|
||||
// Walk our icons, find which one was clicked on, and invoke its
|
||||
// HandleClickEvent() method.
|
||||
gfx::Point cursor_pos(
|
||||
gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
|
||||
win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN);
|
||||
win_icon->HandleClickEvent(
|
||||
cursor_pos,
|
||||
(lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK),
|
||||
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ void NativeImage::SetTemplateImage(bool setAsTemplate) {
|
||||
}
|
||||
|
||||
bool NativeImage::IsTemplateImage() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user