Skip to content

Commit 1e44181

Browse files
feat: add DoubleClick variant for TrayIconEvent (#10786)
* feat: add `DoubleClick` variant for `TrayIconEvent` * revert api example change --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent 3a4972b commit 1e44181

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.changes/tray-double-click.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "patch:feat"
3+
---
4+
5+
On Windows, Add and emit `DoubleClick` variant for `TrayIconEvent`.

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ specta = { version = "^2.0.0-rc.16", optional = true, default-features = false,
8282

8383
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
8484
muda = { version = "0.14", default-features = false, features = ["serde"] }
85-
tray-icon = { version = "0.15", default-features = false, features = ["serde"], optional = true }
85+
tray-icon = { version = "0.16", default-features = false, features = ["serde"], optional = true }
8686

8787
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
8888
gtk = { version = "0.18", features = ["v3_24"] }

core/tauri/src/tray/mod.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ pub enum TrayIconEvent {
9191
/// Mouse button state when this event was triggered.
9292
button_state: MouseButtonState,
9393
},
94+
/// A double click happened on the tray icon. **Windows Only**
95+
DoubleClick {
96+
/// Id of the tray icon which triggered this event.
97+
id: TrayIconId,
98+
/// Physical Position of this event.
99+
position: PhysicalPosition<f64>,
100+
/// Position and size of the tray icon.
101+
rect: Rect,
102+
/// Mouse button that triggered this event.
103+
button: MouseButton,
104+
},
94105
/// The mouse entered the tray icon region.
95106
Enter {
96107
/// Id of the tray icon which triggered this event.
@@ -125,6 +136,7 @@ impl TrayIconEvent {
125136
pub fn id(&self) -> &TrayIconId {
126137
match self {
127138
TrayIconEvent::Click { id, .. } => id,
139+
TrayIconEvent::DoubleClick { id, .. } => id,
128140
TrayIconEvent::Enter { id, .. } => id,
129141
TrayIconEvent::Move { id, .. } => id,
130142
TrayIconEvent::Leave { id, .. } => id,
@@ -151,6 +163,20 @@ impl From<tray_icon::TrayIconEvent> for TrayIconEvent {
151163
button: button.into(),
152164
button_state: button_state.into(),
153165
},
166+
tray_icon::TrayIconEvent::DoubleClick {
167+
id,
168+
position,
169+
rect,
170+
button,
171+
} => TrayIconEvent::DoubleClick {
172+
id,
173+
position,
174+
rect: Rect {
175+
position: rect.position.into(),
176+
size: rect.size.into(),
177+
},
178+
button: button.into(),
179+
},
154180
tray_icon::TrayIconEvent::Enter { id, position, rect } => TrayIconEvent::Enter {
155181
id,
156182
position,

0 commit comments

Comments
 (0)