Add OS file drop event handler
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
5b04f965fa
commit
a01b507ef4
9 changed files with 141 additions and 85 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use gpui2::{hsla, AnyElement, ElementId, Hsla, Length, Size};
|
||||
use gpui2::{hsla, red, AnyElement, DroppedFiles, ElementId, Hsla, Length, Size};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
@ -50,8 +50,19 @@ impl<S: 'static + Send + Sync> Pane<S> {
|
|||
.bg(self.fill)
|
||||
.w(self.size.width)
|
||||
.h(self.size.height)
|
||||
.overflow_y_scroll()
|
||||
.children(self.children.drain(..))
|
||||
.relative()
|
||||
.children(cx.stack(0, |_| self.children.drain(..)))
|
||||
.child(cx.stack(1, |_| {
|
||||
// TODO kb! Figure out why we can't we see the red background when we drag a file over this div.
|
||||
div()
|
||||
.id("drag-target")
|
||||
.drag_over::<DroppedFiles>(|d| d.bg(red()))
|
||||
.on_drop(|_, files: DroppedFiles, _| {
|
||||
dbg!("dropped files!", files);
|
||||
})
|
||||
.absolute()
|
||||
.inset_0()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue