Implement event capturing for PaneGrid
This commit is contained in:
parent
3bcee62beb
commit
31c509b206
3 changed files with 47 additions and 28 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::pane_grid;
|
||||
use crate::{
|
||||
Clipboard, Element, Event, Hasher, Layout, Point, Rectangle, Size,
|
||||
};
|
||||
use crate::{Clipboard, Element, Hasher, Layout, Point, Rectangle, Size};
|
||||
|
||||
/// The title bar of a [`Pane`].
|
||||
///
|
||||
|
|
@ -245,7 +244,7 @@ where
|
|||
messages: &mut Vec<Message>,
|
||||
renderer: &Renderer,
|
||||
clipboard: Option<&dyn Clipboard>,
|
||||
) {
|
||||
) -> event::Status {
|
||||
if let Some(controls) = &mut self.controls {
|
||||
let mut children = layout.children();
|
||||
let padded = children.next().unwrap();
|
||||
|
|
@ -254,14 +253,16 @@ where
|
|||
let _ = children.next();
|
||||
let controls_layout = children.next().unwrap();
|
||||
|
||||
let _ = controls.on_event(
|
||||
controls.on_event(
|
||||
event,
|
||||
controls_layout,
|
||||
cursor_position,
|
||||
messages,
|
||||
renderer,
|
||||
clipboard,
|
||||
);
|
||||
)
|
||||
} else {
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue