From f652e84187336c8bdd9bee32c0afeda7b14796b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 12 Apr 2020 00:38:18 +0200 Subject: [PATCH] Make cursor unavailable on leave in `iced_winit` For now, we just set the cursor position to some negative coordinates. This is a temporary hack until we are able to encode cursor availability. Layers and/or multi-window support will make this apparent. --- native/src/user_interface.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 5d9221e9..88ffd6d6 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -188,8 +188,15 @@ where let mut messages = Vec::new(); for event in events { - if let Event::Mouse(mouse::Event::CursorMoved { x, y }) = event { - self.cursor_position = Point::new(x, y); + match event { + Event::Mouse(mouse::Event::CursorMoved { x, y }) => { + self.cursor_position = Point::new(x, y); + } + Event::Mouse(mouse::Event::CursorLeft) => { + // TODO: Encode cursor availability + self.cursor_position = Point::new(-1.0, -1.0); + } + _ => {} } self.root.widget.on_event(