wip: drag and drop support
This commit is contained in:
1 parent
20a29409b2
commit
9ae981a1af
4 files changed
+85
-71
No files matched your search
@@ -0,0 +1,18 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::desktop::launch_with_props(app, (), |c| {
|
||||
c.with_file_drop_handler(|w, e| {
|
||||
println!("{:?}", e);
|
||||
false
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx!(
|
||||
div {
|
||||
h1 { "drag an file here" }
|
||||
}
|
||||
))
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
Example: Manual Edits
|
||||
|
||||
It's possible to manually provide a stream of DomEdits to a Dioxus Renderer. All renderers are designed to accept a stream
|
||||
of DomEdits that abstract over a stack machine. This allows the VirtualDOM to exist entirely separately from the RealDOM,
|
||||
though features like NodeRefs and NativeEvents might not work properly everywhere.
|
||||
*/
|
||||
|
||||
use dioxus::core::*;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
use DomEdit::*;
|
||||
|
||||
let edits = vec![
|
||||
// create a container and push it onto the stack
|
||||
CreateElement {
|
||||
tag: "div",
|
||||
root: 0,
|
||||
},
|
||||
// create an element and push it onto the stack
|
||||
CreateElement { tag: "h1", root: 2 },
|
||||
// create a text node and push it onto the stack
|
||||
CreateTextNode {
|
||||
text: "hello world",
|
||||
root: 3,
|
||||
},
|
||||
// append the text node to the h1 element
|
||||
AppendChildren { many: 1 },
|
||||
// append the h1 element to the container
|
||||
AppendChildren { many: 1 },
|
||||
// append the container to the default render element ("dioxusroot" if used with default config)
|
||||
AppendChildren { many: 1 },
|
||||
];
|
||||
|
||||
let app: Component = |cx| cx.render(rsx!(div { "some app" }));
|
||||
|
||||
dioxus_desktop::launch_with_props(app, (), |c| c.with_edits(edits));
|
||||
}
|
||||
Reference in new issue
Block a user