Compare commits

...

4 Commits

Author SHA1 Message Date
Amr Bashir 13e6268448 tauri 2.0.0-alpha.12 2023-08-15 03:15:45 +03:00
Amr Bashir 7a605d402b fix fs plugin 2023-08-15 03:12:43 +03:00
Amr Bashir 18635c2200 Merge branch 'v2' into feat/window/dnd-position 2023-08-15 03:11:01 +03:00
Amr Bashir cdae07afe6 feat(window): add drag and drop position 2023-08-14 06:34:55 +03:00
5 changed files with 36 additions and 17 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"window-js": "minor"
---
Add position information to file drop events.
+1 -1
View File
@@ -5,7 +5,7 @@ resolver = "2"
[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
log = "0.4"
tauri = "2.0.0-alpha.11"
tauri = "2.0.0-alpha.12"
tauri-build = "2.0.0-alpha.8"
serde_json = "1"
thiserror = "1"
+1 -1
View File
@@ -83,7 +83,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
.on_event(|app, event| {
if let RunEvent::WindowEvent {
label: _,
event: WindowEvent::FileDrop(FileDropEvent::Dropped(paths)),
event: WindowEvent::FileDrop(FileDropEvent::Dropped { paths, .. }),
..
} = event
{
+28 -14
View File
@@ -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