1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Events produced by state-machine inspectors (keyboard, drag) and
//! consumed by both the core test suite and the view component.
//!
//! Placing `DirectoryTreeEvent` in the core crate lets
//! [`crate::keyboard::handle_key`] return it without a circular dependency,
//! and lets application code depend only on `dioxus-swdir-tree-core` when
//! integrating the widget without a Dioxus renderer.
use PathBuf;
use crateDragMsg;
use crateSelectionMode;
/// An event emitted by the keyboard handler, the view component, or the drag
/// state machine.
///
/// The host handles each variant by calling the corresponding method on
/// `DirectoryTree`:
///
/// ```no_run
/// # use dioxus_swdir_tree_core::{DirectoryTreeEvent, DirectoryTree, SelectionMode};
/// # use dioxus_swdir_tree_core::drag::DragOutcome;
/// # use std::path::Path;
/// fn handle(tree: &mut DirectoryTree, ev: DirectoryTreeEvent) {
/// match ev {
/// DirectoryTreeEvent::Toggled(path) => {
/// let _req = tree.on_toggled(&path);
/// }
/// DirectoryTreeEvent::Selected { path, is_dir, mode } => {
/// tree.on_selected(&path, is_dir, mode);
/// }
/// DirectoryTreeEvent::Drag(msg) => {
/// match tree.on_drag_msg(msg) {
/// DragOutcome::Clicked { path, is_dir } => {
/// tree.on_selected(&path, is_dir, SelectionMode::Replace);
/// }
/// DragOutcome::Completed { sources, destination } => {
/// // application performs the filesystem operation
/// let _ = (sources, destination);
/// }
/// DragOutcome::None => {}
/// }
/// }
/// }
/// }
/// ```