#[non_exhaustive]pub enum FileEvent {
Entered {
pos: Option<Point>,
files: Vec<UploadFile>,
},
Moved {
pos: Option<Point>,
files: Vec<UploadFile>,
},
Left,
Dropped {
pos: Option<Point>,
files: Vec<UploadFile>,
},
Hover {
pos: Point,
files: Vec<UploadFile>,
},
HoverCancelled,
Drop {
pos: Point,
files: Vec<UploadFile>,
},
}Expand description
Platform-neutral file hover/drop event.
Current variants are Entered, Moved, Left, and Dropped; Hover,
HoverCancelled, and Drop remain compatibility variants.
§Examples
use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::dropped(Some(Point::new(2.0, 3.0)), [UploadFile::named("a.txt")]);
assert_eq!(event.files()[0].name, "a.txt");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Entered
A batch of files entered the logical window.
Fields
files: Vec<UploadFile>Files in provider order; the batch may be empty.
Moved
A hovering batch moved within the logical window.
Fields
files: Vec<UploadFile>Current files in provider order; the batch may be empty.
Left
The current file batch left the logical window.
Dropped
A batch of files was dropped in the logical window.
Fields
files: Vec<UploadFile>Dropped files in provider order; the batch may be empty.
Hover
One or more files are hovering over the window at logical pos.
New adapters should use FileEvent::Entered and FileEvent::Moved.
Fields
files: Vec<UploadFile>Hovering files in provider order.
HoverCancelled
File hover was cancelled by the platform.
New adapters should use FileEvent::Left.
Drop
One or more files were dropped at logical pos.
New adapters should use FileEvent::Dropped.
Fields
files: Vec<UploadFile>Dropped files in provider order.
Implementations§
Source§impl FileEvent
impl FileEvent
Sourcepub fn entered(
pos: Option<Point>,
files: impl IntoIterator<Item = UploadFile>,
) -> Self
pub fn entered( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self
Creates an ordered batch that entered the logical window.
None preserves that the provider did not supply a pointer position;
it is not replaced with an origin or stale coordinate.
§Examples
use ailloli_ui_core::{event::FileEvent, UploadFile};
let event = FileEvent::entered(None, [UploadFile::named("a.txt")]);
assert_eq!(event.pos(), None);Sourcepub fn moved(
pos: Option<Point>,
files: impl IntoIterator<Item = UploadFile>,
) -> Self
pub fn moved( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self
Creates an ordered hovering batch movement.
§Examples
use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::moved(Some(Point::new(1.0, 2.0)), [UploadFile::named("a.txt")]);
assert_eq!(event.pos(), Some(Point::new(1.0, 2.0)));Sourcepub const fn left() -> Self
pub const fn left() -> Self
Creates a notification that the current batch left the window.
Leave events carry neither files nor a position.
§Examples
use ailloli_ui_core::event::FileEvent;
assert!(FileEvent::left().is_left());Sourcepub fn dropped(
pos: Option<Point>,
files: impl IntoIterator<Item = UploadFile>,
) -> Self
pub fn dropped( pos: Option<Point>, files: impl IntoIterator<Item = UploadFile>, ) -> Self
Creates an ordered batch dropped in the logical window.
§Examples
use ailloli_ui_core::{event::FileEvent, UploadFile};
assert_eq!(FileEvent::dropped(None, [UploadFile::named("a.txt")]).files().len(), 1);Sourcepub fn pos(&self) -> Option<Point>
pub fn pos(&self) -> Option<Point>
Logical pointer position supplied by the provider, when known.
§Examples
use ailloli_ui_core::{event::FileEvent, Point, UploadFile};
let event = FileEvent::entered(Some(Point::new(3.0, 4.0)), [UploadFile::named("a")]);
assert_eq!(event.pos(), Some(Point::new(3.0, 4.0)));Sourcepub fn files(&self) -> &[UploadFile]
pub fn files(&self) -> &[UploadFile]
Ordered files carried by the event, or an empty slice for leave events.
§Examples
use ailloli_ui_core::event::FileEvent;
assert!(FileEvent::left().files().is_empty());