Restore hotkeys in pane_grid example

- Implement `subscription::events_with`
- Remove `pane_grid::KeyPressEvent`
- Return closest sibling in `pane_grid::State::close`
This commit is contained in:
Héctor Ramón Jiménez 2020-11-10 02:32:57 +01:00
parent c53022e8df
commit d6d5cf0294
9 changed files with 88 additions and 45 deletions

View file

@ -227,12 +227,13 @@ impl<T> State<T> {
let _ = self.internal.layout.resize(split, ratio);
}
/// Closes the given [`Pane`] and returns its internal state, if it exists.
/// Closes the given [`Pane`] and returns its internal state and its closest
/// sibling, if it exists.
///
/// [`Pane`]: struct.Pane.html
pub fn close(&mut self, pane: &Pane) -> Option<T> {
if let Some(_) = self.internal.layout.remove(pane) {
self.panes.remove(pane)
pub fn close(&mut self, pane: &Pane) -> Option<(T, Pane)> {
if let Some(sibling) = self.internal.layout.remove(pane) {
self.panes.remove(pane).map(|state| (state, sibling))
} else {
None
}