Avoid PaneGrid unfocus when cursor is unavailable

This commit is contained in:
Héctor Ramón Jiménez 2020-07-23 04:44:35 +02:00
parent a225a218e0
commit a165eddd75
2 changed files with 5 additions and 1 deletions

View File

@ -496,7 +496,10 @@ where
}
}
} else {
self.state.unfocus();
// TODO: Encode cursor availability in the type system
if cursor_position.x > 0.0 && cursor_position.y > 0.0 {
self.state.unfocus();
}
}
}
mouse::Event::ButtonReleased(mouse::Button::Left) => {

View File

@ -227,6 +227,7 @@ where
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
if *self.is_open {
// TODO: Encode cursor availability in the type system
*self.is_open =
cursor_position.x < 0.0 || cursor_position.y < 0.0;
} else if layout.bounds().contains(cursor_position) {