mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-12 05:31:31 +11:00
Merge pull request #384 from fkaa/keypress-sound
Fix alert sounds on keypress for cocoa
This commit is contained in:
commit
7eeb96909c
|
@ -199,9 +199,11 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
YES);
|
YES);
|
||||||
if event == nil { return None; }
|
if event == nil { return None; }
|
||||||
NSApp().sendEvent_(event);
|
|
||||||
|
|
||||||
let event = match msg_send![event, type] {
|
let event_type = msg_send![event, type];
|
||||||
|
NSApp().sendEvent_(if let NSKeyDown = event_type { nil } else { event });
|
||||||
|
|
||||||
|
let event = match event_type {
|
||||||
NSLeftMouseDown => { Some(MouseInput(Pressed, MouseButton::Left)) },
|
NSLeftMouseDown => { Some(MouseInput(Pressed, MouseButton::Left)) },
|
||||||
NSLeftMouseUp => { Some(MouseInput(Released, MouseButton::Left)) },
|
NSLeftMouseUp => { Some(MouseInput(Released, MouseButton::Left)) },
|
||||||
NSRightMouseDown => { Some(MouseInput(Pressed, MouseButton::Right)) },
|
NSRightMouseDown => { Some(MouseInput(Pressed, MouseButton::Right)) },
|
||||||
|
@ -220,6 +222,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
};
|
};
|
||||||
let view_rect = NSView::frame(*self.window.view);
|
let view_rect = NSView::frame(*self.window.view);
|
||||||
let scale_factor = self.window.hidpi_factor();
|
let scale_factor = self.window.hidpi_factor();
|
||||||
|
|
||||||
Some(MouseMoved(((scale_factor * view_point.x as f32) as i32,
|
Some(MouseMoved(((scale_factor * view_point.x as f32) as i32,
|
||||||
(scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
|
(scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
|
||||||
},
|
},
|
||||||
|
@ -241,6 +244,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
},
|
},
|
||||||
NSKeyUp => {
|
NSKeyUp => {
|
||||||
let vkey = event::vkeycode_to_element(NSEvent::keyCode(event));
|
let vkey = event::vkeycode_to_element(NSEvent::keyCode(event));
|
||||||
|
|
||||||
Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
|
Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
|
||||||
},
|
},
|
||||||
NSFlagsChanged => {
|
NSFlagsChanged => {
|
||||||
|
@ -273,8 +277,6 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
_ => { None },
|
_ => { None },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue