Introduce on_click handler in PaneGrid
This commit is contained in:
parent
5681c83d3c
commit
8008ea5286
3 changed files with 42 additions and 14 deletions
|
|
@ -6,4 +6,4 @@ edition = "2018"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced = { path = "../.." }
|
||||
iced = { path = "../..", features = ["debug"] }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ enum Message {
|
|||
Split(pane_grid::Axis, pane_grid::Pane),
|
||||
SplitFocused(pane_grid::Axis),
|
||||
FocusAdjacent(pane_grid::Direction),
|
||||
Clicked(pane_grid::Pane),
|
||||
Dragged(pane_grid::DragEvent),
|
||||
Resized(pane_grid::ResizeEvent),
|
||||
Close(pane_grid::Pane),
|
||||
|
|
@ -45,22 +46,30 @@ impl Sandbox for Example {
|
|||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::Split(axis, pane) => {
|
||||
let _ = self.panes.split(
|
||||
let result = self.panes.split(
|
||||
axis,
|
||||
&pane,
|
||||
Content::new(self.panes_created),
|
||||
);
|
||||
|
||||
if let Some((pane, _)) = result {
|
||||
self.focus = Some(pane);
|
||||
}
|
||||
|
||||
self.panes_created += 1;
|
||||
}
|
||||
Message::SplitFocused(axis) => {
|
||||
if let Some(pane) = self.focus {
|
||||
let _ = self.panes.split(
|
||||
let result = self.panes.split(
|
||||
axis,
|
||||
&pane,
|
||||
Content::new(self.panes_created),
|
||||
);
|
||||
|
||||
if let Some((pane, _)) = result {
|
||||
self.focus = Some(pane);
|
||||
}
|
||||
|
||||
self.panes_created += 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -73,6 +82,9 @@ impl Sandbox for Example {
|
|||
}
|
||||
}
|
||||
}
|
||||
Message::Clicked(pane) => {
|
||||
self.focus = Some(pane);
|
||||
}
|
||||
Message::Resized(pane_grid::ResizeEvent { split, ratio }) => {
|
||||
self.panes.resize(&split, ratio);
|
||||
}
|
||||
|
|
@ -113,6 +125,7 @@ impl Sandbox for Example {
|
|||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.spacing(10)
|
||||
.on_click(Message::Clicked)
|
||||
.on_drag(Message::Dragged)
|
||||
.on_resize(10, Message::Resized);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue