From a165eddd757cb5d92d75febe1e5655c8077b76e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 23 Jul 2020 04:44:35 +0200 Subject: [PATCH] Avoid `PaneGrid` unfocus when cursor is unavailable --- native/src/widget/pane_grid.rs | 5 ++++- native/src/widget/pick_list.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index dfff388b..5180fd3b 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -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) => { diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs index 3e83fa56..04478225 100644 --- a/native/src/widget/pick_list.rs +++ b/native/src/widget/pick_list.rs @@ -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) {