Skip to content

Commit

Permalink
fix: offset DnD events in scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 5, 2024
1 parent 57288e5 commit 65c7a3d
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,40 @@ where

let translation =
state.translation(self.direction, bounds, content_bounds);
let mut c_event = match event.clone() {

Check warning on line 766 in widget/src/scrollable.rs

View workflow job for this annotation

GitHub Actions / widget

variable does not need to be mutable

Check warning on line 766 in widget/src/scrollable.rs

View workflow job for this annotation

GitHub Actions / wasm

variable does not need to be mutable

Check warning on line 766 in widget/src/scrollable.rs

View workflow job for this annotation

GitHub Actions / wasm

variable does not need to be mutable

Check warning on line 766 in widget/src/scrollable.rs

View workflow job for this annotation

GitHub Actions / todos_macos

variable does not need to be mutable

Check warning on line 766 in widget/src/scrollable.rs

View workflow job for this annotation

GitHub Actions / todos_windows

variable does not need to be mutable
Event::Dnd(dnd::DndEvent::Offer(
id,
dnd::OfferEvent::Enter {
x,
y,
mime_types,
surface,
},
)) => Event::Dnd(dnd::DndEvent::Offer(
id.clone(),
dnd::OfferEvent::Enter {
x: x + translation.x as f64,
y: y + translation.y as f64,
mime_types: mime_types.clone(),
surface: surface.clone(),
},
)),
Event::Dnd(dnd::DndEvent::Offer(
id,
dnd::OfferEvent::Motion { x, y },
)) => Event::Dnd(dnd::DndEvent::Offer(
id.clone(),
dnd::OfferEvent::Motion {
x: x + translation.x as f64,
y: y + translation.y as f64,
},
)),
e => e,
};

self.content.as_widget_mut().on_event(
&mut tree.children[0],
event.clone(),
c_event,
content,
cursor,
renderer,
Expand Down

0 comments on commit 65c7a3d

Please sign in to comment.