diff --git a/src/widget/dnd_destination.rs b/src/widget/dnd_destination.rs index 89c7d44a..121648ab 100644 --- a/src/widget/dnd_destination.rs +++ b/src/widget/dnd_destination.rs @@ -241,6 +241,11 @@ impl<'a, Message: 'static> DndDestination<'a, Message> { Internal::Set(_) => panic!("Invalid Id assigned to dnd destination."), })) } + + pub fn id(mut self, id: Id) -> Self { + self.id = id; + self + } } impl Widget @@ -354,8 +359,12 @@ impl Widget } return event::Status::Captured; } - Event::Dnd(DndEvent::Offer(id, OfferEvent::Leave)) if id == Some(my_id) => { - state.on_leave(self.on_leave.as_ref().map(std::convert::AsRef::as_ref)); + Event::Dnd(DndEvent::Offer(id, OfferEvent::Leave)) => { + if let Some(msg) = + state.on_leave(self.on_leave.as_ref().map(std::convert::AsRef::as_ref)) + { + shell.publish(msg); + } if self.forward_drag_as_cursor { let drag_cursor = mouse::Cursor::Unavailable; @@ -403,7 +412,7 @@ impl Widget } return event::Status::Captured; } - Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if id == Some(my_id) => { + Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) => { if let Some(msg) = state.on_leave(self.on_leave.as_ref().map(std::convert::AsRef::as_ref)) { diff --git a/src/widget/segmented_button/widget.rs b/src/widget/segmented_button/widget.rs index e0c3a2a8..3cb64e2d 100644 --- a/src/widget/segmented_button/widget.rs +++ b/src/widget/segmented_button/widget.rs @@ -733,9 +733,8 @@ where entity, ); } - DndEvent::Offer(id, OfferEvent::Leave | OfferEvent::LeaveDestination) - if Some(my_id) == *id => - { + DndEvent::Offer(id, OfferEvent::LeaveDestination) if Some(my_id) != *id => {} + DndEvent::Offer(id, OfferEvent::Leave | OfferEvent::LeaveDestination) => { if let Some(Some(entity)) = entity { if let Some(on_dnd_leave) = self.on_dnd_leave.as_ref() { shell.publish(on_dnd_leave(entity)); diff --git a/src/widget/text_input/input.rs b/src/widget/text_input/input.rs index 86baa31c..eed1bed1 100644 --- a/src/widget/text_input/input.rs +++ b/src/widget/text_input/input.rs @@ -1995,10 +1995,12 @@ pub fn update<'a, Message: Clone + 'static>( return event::Status::Ignored; } #[cfg(feature = "wayland")] + Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != id => {} + #[cfg(feature = "wayland")] Event::Dnd(DndEvent::Offer( rectangle, OfferEvent::Leave | OfferEvent::LeaveDestination, - )) if rectangle == Some(dnd_id) => { + )) => { cold(); let state = state(); // ASHLEY TODO we should be able to reset but for now we don't if we are handling a