Fix stickiness of main pane drag target

Reimplement the pane drag targets using on_drag_move
This commit is contained in:
Max Brunsfeld
2023-12-14 16:23:15 -08:00
parent 0b4b81fa0c
commit d6383ab0c6
2 changed files with 90 additions and 112 deletions
+4 -2
View File
@@ -33,6 +33,7 @@ pub struct GroupStyle {
pub struct DragMoveEvent<T> {
pub event: MouseMoveEvent,
pub bounds: Bounds<Pixels>,
drag: PhantomData<T>,
}
@@ -208,7 +209,7 @@ pub trait InteractiveElement: Sized {
self
}
fn on_drag_move<T>(
fn on_drag_move<T: 'static>(
mut self,
listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
) -> Self
@@ -223,11 +224,12 @@ pub trait InteractiveElement: Sized {
if cx
.active_drag
.as_ref()
.is_some_and(|drag| (*drag.value).type_id() == TypeId::of::<T>())
.is_some_and(|drag| drag.value.as_ref().type_id() == TypeId::of::<T>())
{
(listener)(
&DragMoveEvent {
event: event.clone(),
bounds: bounds.bounds,
drag: PhantomData,
},
cx,