Replace event::Status in Widget::on_event with Shell::capture_event

This commit is contained in:
Héctor Ramón Jiménez 2024-10-25 19:28:18 +02:00
parent 752403d70c
commit dcc184b01b
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F
44 changed files with 560 additions and 709 deletions

View file

@ -1,11 +1,10 @@
pub use crate::Overlay;
use crate::event::{self, Event};
use crate::layout;
use crate::mouse;
use crate::renderer;
use crate::widget;
use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size};
use crate::{Clipboard, Event, Layout, Point, Rectangle, Shell, Size};
/// A generic [`Overlay`].
#[allow(missing_debug_implementations)]
@ -58,9 +57,9 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> event::Status {
) {
self.overlay
.on_event(event, layout, cursor, renderer, clipboard, shell)
.on_event(event, layout, cursor, renderer, clipboard, shell);
}
/// Returns the current [`mouse::Interaction`] of the [`Element`].
@ -157,11 +156,11 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, B>,
) -> event::Status {
) {
let mut local_messages = Vec::new();
let mut local_shell = Shell::new(&mut local_messages);
let event_status = self.content.on_event(
self.content.on_event(
event,
layout,
cursor,
@ -171,8 +170,6 @@ where
);
shell.merge(local_shell, self.mapper);
event_status
}
fn mouse_interaction(

View file

@ -1,4 +1,3 @@
use crate::event;
use crate::layout;
use crate::mouse;
use crate::overlay;
@ -81,21 +80,17 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> event::Status {
self.children
.iter_mut()
.zip(layout.children())
.map(|(child, layout)| {
child.on_event(
event.clone(),
layout,
cursor,
renderer,
clipboard,
shell,
)
})
.fold(event::Status::Ignored, event::Status::merge)
) {
for (child, layout) in self.children.iter_mut().zip(layout.children()) {
child.on_event(
event.clone(),
layout,
cursor,
renderer,
clipboard,
shell,
);
}
}
fn draw(