fix(dnd): leave event handlers should expect None as the drag Id
This commit is contained in:
parent
a46483f161
commit
ce56237ab9
3 changed files with 17 additions and 7 deletions
|
|
@ -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<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||
|
|
@ -354,8 +359,12 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
|||
}
|
||||
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<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
|||
}
|
||||
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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue