mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-30 17:48:50 +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.
|
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. */
|
/** The file drop event types. */
|
||||||
type FileDropEvent =
|
type FileDropEvent =
|
||||||
| { type: "hover"; paths: string[] }
|
| { type: "hover"; paths: string[]; position: PhysicalPosition }
|
||||||
| { type: "drop"; paths: string[] }
|
| { type: "drop"; paths: string[]; position: PhysicalPosition }
|
||||||
| { type: "cancel" };
|
| { type: "cancel" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1901,19 +1901,33 @@ class Window {
|
|||||||
async onFileDropEvent(
|
async onFileDropEvent(
|
||||||
handler: EventCallback<FileDropEvent>,
|
handler: EventCallback<FileDropEvent>,
|
||||||
): Promise<UnlistenFn> {
|
): Promise<UnlistenFn> {
|
||||||
const unlistenFileDrop = await this.listen<string[]>(
|
const unlistenFileDrop = await this.listen<{
|
||||||
TauriEvent.WINDOW_FILE_DROP,
|
paths: string[];
|
||||||
(event) => {
|
position: PhysicalPosition;
|
||||||
handler({ ...event, payload: { type: "drop", paths: event.payload } });
|
}>(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[]>(
|
const unlistenFileHover = await this.listen<{
|
||||||
TauriEvent.WINDOW_FILE_DROP_HOVER,
|
paths: string[];
|
||||||
(event) => {
|
position: PhysicalPosition;
|
||||||
handler({ ...event, payload: { type: "hover", paths: event.payload } });
|
}>(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>(
|
const unlistenCancel = await this.listen<null>(
|
||||||
TauriEvent.WINDOW_FILE_DROP_CANCELLED,
|
TauriEvent.WINDOW_FILE_DROP_CANCELLED,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user