mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Fix key state on MacOS (#610)
This commit is contained in:
parent
3910326709
commit
01cb8e59e3
|
@ -1,5 +1,6 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On MacOS, the key state for modifiers key events is now properly set.
|
||||||
- On iOS, the view is now set correctly. This makes it possible to render things (instead of being stuck on a black screen), and touch events work again.
|
- On iOS, the view is now set correctly. This makes it possible to render things (instead of being stuck on a black screen), and touch events work again.
|
||||||
- Added NetBSD support.
|
- Added NetBSD support.
|
||||||
|
|
||||||
|
|
|
@ -674,11 +674,15 @@ pub fn event_mods(event: cocoa::base::id) -> ModifiersState {
|
||||||
unsafe fn modifier_event(
|
unsafe fn modifier_event(
|
||||||
ns_event: cocoa::base::id,
|
ns_event: cocoa::base::id,
|
||||||
keymask: NSEventModifierFlags,
|
keymask: NSEventModifierFlags,
|
||||||
key_pressed: bool,
|
was_key_pressed: bool,
|
||||||
) -> Option<WindowEvent> {
|
) -> Option<WindowEvent> {
|
||||||
if !key_pressed && NSEvent::modifierFlags(ns_event).contains(keymask)
|
if !was_key_pressed && NSEvent::modifierFlags(ns_event).contains(keymask)
|
||||||
|| key_pressed && !NSEvent::modifierFlags(ns_event).contains(keymask) {
|
|| was_key_pressed && !NSEvent::modifierFlags(ns_event).contains(keymask) {
|
||||||
let state = ElementState::Released;
|
let state = if was_key_pressed {
|
||||||
|
ElementState::Released
|
||||||
|
} else {
|
||||||
|
ElementState::Pressed
|
||||||
|
};
|
||||||
let keycode = NSEvent::keyCode(ns_event);
|
let keycode = NSEvent::keyCode(ns_event);
|
||||||
let scancode = keycode as u32;
|
let scancode = keycode as u32;
|
||||||
let virtual_keycode = to_virtual_key_code(keycode);
|
let virtual_keycode = to_virtual_key_code(keycode);
|
||||||
|
|
Loading…
Reference in a new issue