Merge pull request #289 from hecrj/fix/cursor-events
Produce and handle `CursorEntered` and `CursorLeft`
This commit is contained in:
commit
bc70ba12f1
@ -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(
|
||||
|
@ -27,6 +27,12 @@ pub fn window_event(
|
||||
height: logical_size.height,
|
||||
}))
|
||||
}
|
||||
WindowEvent::CursorEntered { .. } => {
|
||||
Some(Event::Mouse(mouse::Event::CursorEntered))
|
||||
}
|
||||
WindowEvent::CursorLeft { .. } => {
|
||||
Some(Event::Mouse(mouse::Event::CursorLeft))
|
||||
}
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
let position = position.to_logical::<f64>(scale_factor);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user