Add viewport to Widget::on_event
This commit is contained in:
parent
e462f48a5a
commit
42c423b4a8
30 changed files with 77 additions and 5 deletions
|
|
@ -278,6 +278,7 @@ where
|
|||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
_viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
update(
|
||||
tree.state.downcast_mut::<State>(),
|
||||
|
|
@ -288,7 +289,7 @@ where
|
|||
shell,
|
||||
self.direction,
|
||||
&self.on_scroll,
|
||||
|event, layout, cursor, clipboard, shell| {
|
||||
|event, layout, cursor, clipboard, shell, viewport| {
|
||||
self.content.as_widget_mut().on_event(
|
||||
&mut tree.children[0],
|
||||
event,
|
||||
|
|
@ -297,6 +298,7 @@ where
|
|||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
@ -492,6 +494,7 @@ pub fn update<Message>(
|
|||
mouse::Cursor,
|
||||
&mut dyn Clipboard,
|
||||
&mut Shell<'_, Message>,
|
||||
&Rectangle,
|
||||
) -> event::Status,
|
||||
) -> event::Status {
|
||||
let bounds = layout.bounds();
|
||||
|
|
@ -518,7 +521,20 @@ pub fn update<Message>(
|
|||
_ => mouse::Cursor::Unavailable,
|
||||
};
|
||||
|
||||
update_content(event.clone(), content, cursor, clipboard, shell)
|
||||
let translation = state.translation(direction, bounds, content_bounds);
|
||||
|
||||
update_content(
|
||||
event.clone(),
|
||||
content,
|
||||
cursor,
|
||||
clipboard,
|
||||
shell,
|
||||
&Rectangle {
|
||||
y: bounds.y + translation.y,
|
||||
x: bounds.x + translation.x,
|
||||
..bounds
|
||||
},
|
||||
)
|
||||
};
|
||||
|
||||
if let event::Status::Captured = event_status {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue