mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-23 11:36:13 +02:00
feat(window): add drag and drop position
This commit is contained in:
@@ -28,4 +28,3 @@
|
||||
---
|
||||
|
||||
Fixes docs.rs build by enabling the `tauri/dox` feature flag.
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"window-js": "minor"
|
||||
---
|
||||
|
||||
Add position information to file drop events.
|
||||
@@ -63,8 +63,8 @@ interface ScaleFactorChanged {
|
||||
|
||||
/** The file drop event types. */
|
||||
type FileDropEvent =
|
||||
| { type: "hover"; paths: string[] }
|
||||
| { type: "drop"; paths: string[] }
|
||||
| { type: "hover"; paths: string[]; position: PhysicalPosition }
|
||||
| { type: "drop"; paths: string[]; position: PhysicalPosition }
|
||||
| { type: "cancel" };
|
||||
|
||||
/**
|
||||
@@ -1901,19 +1901,33 @@ class Window {
|
||||
async onFileDropEvent(
|
||||
handler: EventCallback<FileDropEvent>,
|
||||
): Promise<UnlistenFn> {
|
||||
const unlistenFileDrop = await this.listen<string[]>(
|
||||
TauriEvent.WINDOW_FILE_DROP,
|
||||
(event) => {
|
||||
handler({ ...event, payload: { type: "drop", paths: event.payload } });
|
||||
},
|
||||
);
|
||||
const unlistenFileDrop = await this.listen<{
|
||||
paths: string[];
|
||||
position: PhysicalPosition;
|
||||
}>(TauriEvent.WINDOW_FILE_DROP, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: "drop",
|
||||
paths: event.payload.paths,
|
||||
position: mapPhysicalPosition(event.payload.position),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const unlistenFileHover = await this.listen<string[]>(
|
||||
TauriEvent.WINDOW_FILE_DROP_HOVER,
|
||||
(event) => {
|
||||
handler({ ...event, payload: { type: "hover", paths: event.payload } });
|
||||
},
|
||||
);
|
||||
const unlistenFileHover = await this.listen<{
|
||||
paths: string[];
|
||||
position: PhysicalPosition;
|
||||
}>(TauriEvent.WINDOW_FILE_DROP_HOVER, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: "hover",
|
||||
paths: event.payload.paths,
|
||||
position: mapPhysicalPosition(event.payload.position),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const unlistenCancel = await this.listen<null>(
|
||||
TauriEvent.WINDOW_FILE_DROP_CANCELLED,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user