Merge pull request #496 from hecrj/fix/cursor-position-on-leave
Fix cursor position after a `CursorLeft` event
This commit is contained in:
commit
fb015a85d2
|
@ -148,6 +148,7 @@ pub fn run<A, E, C>(
|
||||||
.expect("Open window");
|
.expect("Open window");
|
||||||
|
|
||||||
let clipboard = Clipboard::new(&window);
|
let clipboard = Clipboard::new(&window);
|
||||||
|
// TODO: Encode cursor availability in the type-system
|
||||||
let mut cursor_position = winit::dpi::PhysicalPosition::new(-1.0, -1.0);
|
let mut cursor_position = winit::dpi::PhysicalPosition::new(-1.0, -1.0);
|
||||||
let mut mouse_interaction = mouse::Interaction::default();
|
let mut mouse_interaction = mouse::Interaction::default();
|
||||||
let mut modifiers = winit::event::ModifiersState::default();
|
let mut modifiers = winit::event::ModifiersState::default();
|
||||||
|
@ -378,6 +379,10 @@ pub fn handle_window_event(
|
||||||
WindowEvent::CursorMoved { position, .. } => {
|
WindowEvent::CursorMoved { position, .. } => {
|
||||||
*cursor_position = *position;
|
*cursor_position = *position;
|
||||||
}
|
}
|
||||||
|
WindowEvent::CursorLeft { .. } => {
|
||||||
|
// TODO: Encode cursor availability in the type-system
|
||||||
|
*cursor_position = winit::dpi::PhysicalPosition::new(-1.0, -1.0);
|
||||||
|
}
|
||||||
WindowEvent::ModifiersChanged(new_modifiers) => {
|
WindowEvent::ModifiersChanged(new_modifiers) => {
|
||||||
*modifiers = *new_modifiers;
|
*modifiers = *new_modifiers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,12 @@ pub fn window_event(
|
||||||
y: position.y as f32,
|
y: position.y as f32,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
WindowEvent::CursorEntered { .. } => {
|
||||||
|
Some(Event::Mouse(mouse::Event::CursorEntered))
|
||||||
|
}
|
||||||
|
WindowEvent::CursorLeft { .. } => {
|
||||||
|
Some(Event::Mouse(mouse::Event::CursorLeft))
|
||||||
|
}
|
||||||
WindowEvent::MouseInput { button, state, .. } => {
|
WindowEvent::MouseInput { button, state, .. } => {
|
||||||
let button = mouse_button(*button);
|
let button = mouse_button(*button);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue