Implement event capturing for PaneGrid

This commit is contained in:
Héctor Ramón Jiménez 2020-11-12 00:40:00 +01:00
parent 3bcee62beb
commit 31c509b206
3 changed files with 47 additions and 28 deletions

View file

@ -1,8 +1,9 @@
use crate::container;
use crate::event::{self, Event};
use crate::layout;
use crate::overlay;
use crate::pane_grid::{self, TitleBar};
use crate::{Clipboard, Element, Event, Hasher, Layout, Point, Size};
use crate::{Clipboard, Element, Hasher, Layout, Point, Size};
/// The content of a [`Pane`].
///
@ -154,11 +155,13 @@ where
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
) -> event::Status {
let mut event_status = event::Status::Ignored;
let body_layout = if let Some(title_bar) = &mut self.title_bar {
let mut children = layout.children();
title_bar.on_event(
event_status = title_bar.on_event(
event.clone(),
children.next().unwrap(),
cursor_position,
@ -172,7 +175,7 @@ where
layout
};
let _ = self.body.on_event(
let body_status = self.body.on_event(
event,
body_layout,
cursor_position,
@ -180,6 +183,8 @@ where
renderer,
clipboard,
);
event_status.merge(body_status)
}
pub(crate) fn hash_layout(&self, state: &mut Hasher) {