crabnebula-dev / drag-rs Goto Github PK
View Code? Open in Web Editor NEWDraggable for GUI apps
Home Page: https://crabnebula.dev
License: Apache License 2.0
Draggable for GUI apps
Home Page: https://crabnebula.dev
License: Apache License 2.0
Hello.
I came from this tauri issue where you said this plugin supports native drag & drop into the file system as electron . Here is a gif of the behavior in electron:
However, it seems that this plugin can only provide x and y coordinate of drop position, not the native file path , already mentioned in #29 .
Is it possible to achieve this feature or it has been achieved but I didn't notice ?
Appreciate it for your answer. ๐
kuchiki
is unmaintained
Details | |
---|---|
Status | unmaintained |
Package | kuchiki |
Version | 0.8.1 |
URL | kuchiki-rs/kuchiki@f92e4c0 |
Date | 2023-01-21 |
The kuchiki
repo was marked as archived in this commit.
Possible alternatives may include:
See advisory page for additional details.
Hi,
I'm developing an application with Iced-rs and tried integrating this, however this still depends on raw window handle version 0.5. 0.6 has a few breaking changes which would need to be addressed. I'm currently trying to do this myself and will do a pr if you want me to and I manage to figure this out, but don't have much experience with the mac and win APIs.
Thanks
On Windows, when a path containing forward slashes is passed as the items to drag, it causes tauri to crash.
Minimal example: Edit the tauri-app
example as follows:
diff --git a/examples/tauri/index.html b/examples/tauri/index.html
index bbf2553..978ca18 100644
--- a/examples/tauri/index.html
+++ b/examples/tauri/index.html
@@ -27,10 +27,11 @@
document.getElementById('drag').ondragstart = async (event) => {
event.preventDefault();
- const path = await window.__TAURI__.path.resolveResource('../icon.png')
+ let path = await window.__TAURI__.path.resolveResource('../icon.png')
+ path = path.replaceAll("\\", "/");
window.__TAURI__.drag.startDrag({ item: [path], icon: path });
};
</script>
</body>
</html>
Alternatively, replace path
with a static string with forward slashes like:
const path = "C:/Files/my-cool-file.png";
Both will cause Tauri to crash upon dragging.
Backtrace:
thread 'main' panicked at crates\drag\src\platform_impl\windows\mod.rs:285:60:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72
2: core::panicking::panic
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:127
3: enum2$<core::option::Option<windows::Windows::Win32::UI::Shell::IShellItemArray> >::unwrap<windows::Windows::Win32::UI::Shell::IShellItemArray>
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\option.rs:935
4: drag::platform_impl::platform::get_file_data_object
at .\crates\drag\src\platform_impl\windows\mod.rs:285
5: drag::platform_impl::platform::start_drag<tauri::window::Window<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > >
at .\crates\drag\src\platform_impl\windows\mod.rs:202
6: tauri_plugin_drag::start_drag::async_fn$0::closure$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
at .\crates\tauri-plugin\src\lib.rs:49
7: core::ops::function::FnOnce::call_once<tauri_plugin_drag::start_drag::async_fn$0::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >,tuple$<> >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\ops\function.rs:250
8: alloc::boxed::impl$47::call_once<tuple$<>,dyn$<core::ops::function::FnOnce<tuple$<>,assoc$<Output,tuple$<> > >,core::marker::Send>,alloc::alloc::Global>
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\alloc\src\boxed.rs:2007
9: tauri_runtime_wry::handle_user_message<enum2$<tauri::EventLoopMessage> >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.2\src\lib.rs:2411
10: tauri_runtime_wry::handle_event_loop<enum2$<tauri::EventLoopMessage> >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.2\src\lib.rs:3075
11: tauri_runtime_wry::impl$47::run::closure$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventL
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.2\src\lib.rs:2342
12: tao::platform_impl::platform::event_loop::impl$2::run_return::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$47::run::closure_env$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:234
13: alloc::boxed::impl$48::call_mut<tuple$<enum2$<tao::event::Event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,ref_mut$<enum2$<tao::event_loop::ControlFlow> > >,dyn$<core::ops::function::FnMut<tuple$<enum2$<tao::event::Event<enu
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\alloc\src\boxed.rs:2014
14: tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop\runner.rs:250
15: core::panic::unwind_safe::impl$23::call_once<tuple$<>,tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\panic\unwind_safe.rs:271
16: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panicking.rs:504
17: tauri::endpoints::app::_::impl$0::deserialize::impl$0::expecting
18: std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > > >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panicking.rs:468
19: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panic.rs:142
20: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::catch_unwind<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tuple$<>,tao::platform_impl::plat
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop\runner.rs:156
21: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::call_event_handler<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop\runner.rs:242
22: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::send_event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop\runner.rs:224
23: tao::platform_impl::platform::event_loop::ThreadMsgTargetSubclassInput<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::send_event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:127
24: tao::platform_impl::platform::event_loop::thread_event_target_callback::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:2226
25: core::ops::function::FnOnce::call_once<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >,tuple$<> >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\ops\function.rs:250
26: core::panic::unwind_safe::impl$23::call_once<windows::Windows::Win32::Foundation::LRESULT,tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\panic\unwind_safe.rs:271
27: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,windows::Windows::Win32
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panicking.rs:504
28: std::panicking::try::do_catch<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::closure_env$1<core::pin::Pin<alloc::boxed::Box<enum2$<tauri::hooks::impl$7::respond_async::async_block_env$0<tauri_runtime_wry::Wry<enum2$
29: std::panicking::try<windows::Windows::Win32::Foundation::LRESULT,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMess
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panicking.rs:468
30: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,windows::Windows::Win32::Fo
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\std\src\panic.rs:142
31: tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::catch_unwind<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,windows::Windows::Win32::Foundati
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop\runner.rs:156
32: tao::platform_impl::platform::event_loop::thread_event_target_callback<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:2275
33: DefSubclassProc
34: DSA_Create
35: CallWindowProcW
36: DispatchMessageW
37: windows::Windows::Win32::UI::WindowsAndMessaging::DispatchMessageW
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-0.39.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:2671
38: tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run_return<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$47::run::closure_env$0<en
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:264
39: tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$47::run::closure_env$0<enum2$<ta
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\platform_impl\windows\event_loop.rs:218
40: tao::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$47::run::closure_env$0<enum2$<tauri::EventLoopMessage>,ta
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.5\src\event_loop.rs:179
41: tauri_runtime_wry::impl$47::run<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage>
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.2\src\lib.rs:2314
42: tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri_utils::assets::
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-1.5.3\src\app.rs:868
43: tauri::app::Builder<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri_utils::assets::EmbeddedAssets>
at C:\Users\James\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-1.5.3\src\app.rs:1722
44: tauri_app::main
at .\examples\tauri\src\main.rs:2
45: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\ops\function.rs:250
Hi all! As mentioned in the title, is there a callback that provides me with the dropped file path? Using the example located over at examples/tauri-dragout
provides me with the x and y position of the mouse and the status of aforementioned dropped file.
I did notice there was an issue closed a while back that mentioned requiring a callback or some sort of function that provides them with the dropped path. From what I see, I'm not too sure how to implement it and it's not really documented.
Thanks!
As far as I can tell these are the two roadblocks to getting this working with Tauri 2.0:
HasRawWindowHandle
is deprecated due to tauri-2.0.0-beta.3
upgrading to raw-window-handle
0.6.0.Any plans to get this crate working with 2.0 Beta or are we waiting for a Release Candidate?
I am on macos, the tauri v1 app crashes as soon as i call startDrag.
import { startDrag } from "@crabnebula/tauri-plugin-drag";
async onmousedown()
{
const item = this.action.options.dropped_paths[0]; // example: /Users/skyslide/Desktop/favicon.png (32x32)
if(!item) return;
startDrag({item: [item], icon: null}) // or icon = item
}
When i don't pass the icon key at all it doesn't crash, but no drag either.
The file definitly exist and the app has access to /Desktop.
There is no message in the terminal when the app closes...
npm run tauri info
output:
[โ] Environment
- OS: Mac OS 14.1.2 X64
โ Xcode Command Line Tools: installed
โ rustc: 1.74.0 (79e9716c9 2023-11-13)
โ cargo: 1.74.0 (ecb9851af 2023-10-18)
โ rustup: 1.26.0 (5af9b9484 2023-04-05)
โ Rust toolchain: stable-x86_64-apple-darwin (default)
- node: 21.2.0
- pnpm: 8.14.0
- yarn: 1.22.21
- npm: 10.2.3
[-] Packages
- tauri [RUST]: 1.5.3
- tauri-build [RUST]: 1.5.0
- wry [RUST]: 0.24.6
- tao [RUST]: 0.16.5
- tauri-cli [RUST]: 1.5.7
- @tauri-apps/api [NPM]: 1.5.1 (outdated, latest: 1.5.3)
- @tauri-apps/cli [NPM]: 1.5.7 (outdated, latest: 1.5.9)
[-] App
- build-type: bundle
- CSP: default-src 'self' https://*.fontawesome.com https://kit.fontawesome.com 'unsafe-inline'; style-src 'self' https://*.fontawesome.com https://kit.fontawesome.com 'unsafe-inline'; script-src 'self' 'unsafe-inline' ; img-src 'self' asset: https://asset.localhost
- distDir: ../dist
- devPath: http://localhost:8080/
- framework: Svelte
- bundler: Vite
main.rs:
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use tauri::{Manager, WindowBuilder};
mod commands;
mod device_listener;
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_drag::init())
.setup(|app| {
let handle = app.handle();
crate::device_listener::create_device_query_listener(handle);
let window = app.get_window("main").unwrap();
Ok(())
})
.invoke_handler(tauri::generate_handler![
crate::commands::console_log,
// and more
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
I have also tested your example at https://github.com/crabnebula-dev/drag-rs/blob/main/examples/tauri/index.html and it crashes the app aswell
I hope to add a custom command to be executed after dragging. It can be any system command instead of just copying the file to the path. This will greatly improve the degree of freedom. For example, if I want to create a shortcut to the dragged file, I may need to first Create this shortcut method locally. After dragging, I still need to manually delete the temporarily created shortcut. The premise of these operations is that I need to obtain the target path first, but there seems to be no relevant API provided at present.
At some point, a file drag operation may require movement.
safemem is unmaintained
Details | |
---|---|
Status | unmaintained |
Package | safemem |
Version | 0.3.3 |
URL | https://github.com/abonander/safemem |
Date | 2023-02-14 |
The latest crates.io release was in 2019. The repository has been archived by the author.
See advisory page for additional details.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.