pub struct FileDropZone { /* private fields */ }Expand description
A click-and-drop file target.
let drop = FileDropZone::new().show(ui);
if drop.response.clicked() {
// Open a native file picker, e.g. via the `rfd` crate.
}
for file in &drop.dropped_files {
// Handle file.path / file.bytes.
let _ = file;
}Implementations§
Source§impl FileDropZone
impl FileDropZone
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a drop zone with the default prompt, action word, and minimum height.
Sourcepub fn prompt(self, prompt: impl Into<WidgetText>) -> Self
pub fn prompt(self, prompt: impl Into<WidgetText>) -> Self
Override the prompt text. Defaults to “Drop files here, or browse”, where the action word is rendered in the sky accent.
Sourcepub fn action_word(self, word: impl Into<String>) -> Self
pub fn action_word(self, word: impl Into<String>) -> Self
Override the action word rendered in the sky accent inside the
prompt. Defaults to "browse". Ignored if Self::prompt is set.
Sourcepub fn hint(self, hint: impl Into<WidgetText>) -> Self
pub fn hint(self, hint: impl Into<WidgetText>) -> Self
Set the hint line under the prompt (e.g. accepted formats and size limits). Defaults to no hint.
Sourcepub fn min_height(self, h: f32) -> Self
pub fn min_height(self, h: f32) -> Self
Override the minimum height of the zone in points. Defaults to 120.
Sourcepub fn show(self, ui: &mut Ui) -> FileDropResponse
pub fn show(self, ui: &mut Ui) -> FileDropResponse
Render the zone and return the response plus any files dropped on its rect this frame.
Trait Implementations§
Source§impl Debug for FileDropZone
impl Debug for FileDropZone
Auto Trait Implementations§
impl Freeze for FileDropZone
impl RefUnwindSafe for FileDropZone
impl Send for FileDropZone
impl Sync for FileDropZone
impl Unpin for FileDropZone
impl UnsafeUnpin for FileDropZone
impl UnwindSafe for FileDropZone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more