Update mouse position during file drag and drop
This commit is contained in:
+20
-13
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, AsyncWindowContext, AvailableSpace,
|
||||
Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, ExternalPaths,
|
||||
Edges, Effect, Element, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId,
|
||||
Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, Edges, Effect,
|
||||
Element, EntityId, EventEmitter, ExternalPaths, FileDropEvent, FocusEvent, FontId,
|
||||
GlobalElementId, GlyphId, Handle, Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch,
|
||||
KeyMatcher, Keystroke, LayoutId, MainThread, MainThreadOnly, Modifiers, MonochromeSprite,
|
||||
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas,
|
||||
@@ -899,6 +899,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {
|
||||
}
|
||||
InputEvent::FileDrop(file_drop) => match file_drop {
|
||||
FileDropEvent::Entered { position, files } => {
|
||||
self.window.mouse_position = position;
|
||||
self.active_drag.get_or_insert_with(|| AnyDrag {
|
||||
drag_handle_view: None,
|
||||
cursor_offset: position,
|
||||
@@ -912,17 +913,23 @@ impl<'a, 'w> WindowContext<'a, 'w> {
|
||||
modifiers: Modifiers::default(),
|
||||
})
|
||||
}
|
||||
FileDropEvent::Pending { position } => InputEvent::MouseMove(MouseMoveEvent {
|
||||
position,
|
||||
pressed_button: Some(MouseButton::Left),
|
||||
modifiers: Modifiers::default(),
|
||||
}),
|
||||
FileDropEvent::Submit { position } => InputEvent::MouseUp(MouseUpEvent {
|
||||
button: MouseButton::Left,
|
||||
position,
|
||||
modifiers: Modifiers::default(),
|
||||
click_count: 1,
|
||||
}),
|
||||
FileDropEvent::Pending { position } => {
|
||||
self.window.mouse_position = position;
|
||||
InputEvent::MouseMove(MouseMoveEvent {
|
||||
position,
|
||||
pressed_button: Some(MouseButton::Left),
|
||||
modifiers: Modifiers::default(),
|
||||
})
|
||||
}
|
||||
FileDropEvent::Submit { position } => {
|
||||
self.window.mouse_position = position;
|
||||
InputEvent::MouseUp(MouseUpEvent {
|
||||
button: MouseButton::Left,
|
||||
position,
|
||||
modifiers: Modifiers::default(),
|
||||
click_count: 1,
|
||||
})
|
||||
}
|
||||
FileDropEvent::Exited => InputEvent::MouseUp(MouseUpEvent {
|
||||
button: MouseButton::Left,
|
||||
position: Point::default(),
|
||||
|
||||
@@ -56,7 +56,6 @@ impl<S: 'static + Send + Sync> Pane<S> {
|
||||
.children(self.children.drain(..)),
|
||||
)
|
||||
.child(
|
||||
// TODO kb! Figure out why we can't we see the red background when we drag a file over this div.
|
||||
div()
|
||||
.z_index(1)
|
||||
.id("drag-target")
|
||||
|
||||
Reference in New Issue
Block a user