Enhance file drop handling and add logging for events

This commit is contained in:
Thorsten Sommer 2025-10-22 20:20:01 +02:00
parent 77bd3b389c
commit 085cf29fed
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -7,7 +7,7 @@ use rocket::serde::json::Json;
use rocket::serde::Serialize; use rocket::serde::Serialize;
use serde::Deserialize; use serde::Deserialize;
use tauri::updater::UpdateResponse; use tauri::updater::UpdateResponse;
use tauri::{Manager, PathResolver, Window}; use tauri::{FileDropEvent, Manager, PathResolver, Window};
use tauri::api::dialog::blocking::FileDialogBuilder; use tauri::api::dialog::blocking::FileDialogBuilder;
use tokio::time; use tokio::time;
use crate::api_token::APIToken; use crate::api_token::APIToken;
@ -31,8 +31,30 @@ pub fn start_tauri() {
// Register a callback for file drop events: // Register a callback for file drop events:
window.on_window_event(|event| window.on_window_event(|event|
if let tauri::WindowEvent::FileDrop(files) = event { match event {
info!(Source = "Tauri"; "files were dropped: {files:?}"); tauri::WindowEvent::FileDrop(drop_event) => {
match drop_event {
FileDropEvent::Hovered(files) => {
info!(Source = "Tauri"; "Files hovered over the window: {files:?}");
},
FileDropEvent::Dropped(files) => {
info!(Source = "Tauri"; "Files dropped on the window: {files:?}");
},
FileDropEvent::Cancelled => {
info!(Source = "Tauri"; "File drop was cancelled.");
},
_ => {}
}
},
tauri::WindowEvent::Focused(state) => {
info!(Source = "Tauri"; "Window focus changed: focused={state}");
},
_ => {}
} }
); );