Fix F10 and Alt+F handling on Windows (#24745)

Closes #24744
and should also fix #17819 

The change is split into two commits, first one adds F10 handling (it
needs to be handled inside `parse_syskeydown_msg_keystroke`, the second
one properly handles `Alt+Fn` combinations, this also needs to happen in
`parse_syskeydown_msg_keystroke` and is similar to a fragment inside
`parse_keydown_msg_keystroke`

Release Notes:

- Fixes F10 and Alt+Fn handling on windows
This commit is contained in:
GiM 2025-02-17 07:43:18 +01:00 committed by GitHub
parent 58491807a4
commit 8b088b3985
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1201,14 +1201,23 @@ fn handle_system_theme_changed(
fn parse_syskeydown_msg_keystroke(wparam: WPARAM) -> Option<Keystroke> {
let modifiers = current_modifiers();
if !modifiers.alt {
// on Windows, F10 can trigger this event, not just the alt key
// and we just don't care about F10
return None;
}
let vk_code = wparam.loword();
// on Windows, F10 can trigger this event, not just the alt key,
// so when F10 was pressed, handle only it
if !modifiers.alt {
if vk_code == VK_F10.0 {
let offset = vk_code - VK_F1.0;
return Some(Keystroke {
modifiers,
key: format!("f{}", offset + 1),
key_char: None,
});
} else {
return None;
}
}
let key = match VIRTUAL_KEY(vk_code) {
VK_BACK => "backspace",
VK_RETURN => "enter",
@ -1226,7 +1235,23 @@ fn parse_syskeydown_msg_keystroke(wparam: WPARAM) -> Option<Keystroke> {
VK_ESCAPE => "escape",
VK_INSERT => "insert",
VK_DELETE => "delete",
_ => return basic_vkcode_to_string(vk_code, modifiers),
_ => {
let basic_key = basic_vkcode_to_string(vk_code, modifiers);
if basic_key.is_some() {
return basic_key;
} else {
if vk_code >= VK_F1.0 && vk_code <= VK_F24.0 {
let offset = vk_code - VK_F1.0;
return Some(Keystroke {
modifiers,
key: format!("f{}", offset + 1),
key_char: None,
});
} else {
return None;
}
}
}
}
.to_owned();