mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix double arrow keys
This commit is contained in:
@@ -70,7 +70,7 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
|
||||
|
||||
key_event.type_ = match (event.state, &event.logical_key) {
|
||||
(ElementState::Pressed, winit::keyboard::Key::Character(_)) => cef_key_event_type_t::KEYEVENT_CHAR,
|
||||
(ElementState::Pressed, _) => cef_key_event_type_t::KEYEVENT_KEYDOWN,
|
||||
(ElementState::Pressed, _) => cef_key_event_type_t::KEYEVENT_RAWKEYDOWN,
|
||||
(ElementState::Released, _) => cef_key_event_type_t::KEYEVENT_KEYUP,
|
||||
}
|
||||
.into();
|
||||
@@ -87,6 +87,14 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
|
||||
key_event.character = key_to_char(&event.logical_key) as u16;
|
||||
key_event.unmodified_character = key_to_char(&event.key_without_modifiers) as u16;
|
||||
|
||||
#[cfg(target_os = "macos")] // See https://www.magpcss.org/ceforum/viewtopic.php?start=10&t=11650
|
||||
if key_event.character == 0
|
||||
&& key_event.unmodified_character == 0
|
||||
&& let Some(text) = &event.text_with_all_modifiers
|
||||
{
|
||||
key_event.character = text.chars().next().unwrap_or_default() as u16;
|
||||
}
|
||||
|
||||
host.send_key_event(Some(&key_event));
|
||||
|
||||
fn key_to_char(key: &winit::keyboard::Key) -> char {
|
||||
|
||||
@@ -49,10 +49,10 @@ impl ToVKBits for winit::keyboard::NamedKey {
|
||||
(0x5B, Meta),
|
||||
(0x0D, Enter),
|
||||
(0x09, Tab),
|
||||
(0x28, ArrowDown),
|
||||
(0x25, ArrowLeft),
|
||||
(0x27, ArrowRight),
|
||||
(0x26, ArrowUp),
|
||||
(0x27, ArrowRight),
|
||||
(0x28, ArrowDown),
|
||||
(0x23, End),
|
||||
(0x24, Home),
|
||||
(0x22, PageDown),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use winit::event_loop::ActiveEventLoop;
|
||||
use winit::platform::macos::{OptionAsAlt, WindowAttributesMacOS};
|
||||
use winit::platform::macos::WindowAttributesMacOS;
|
||||
use winit::window::{Window, WindowAttributes};
|
||||
|
||||
use crate::consts::APP_NAME;
|
||||
@@ -15,8 +15,7 @@ impl super::NativeWindow for NativeWindowImpl {
|
||||
let mac_window = WindowAttributesMacOS::default()
|
||||
.with_titlebar_transparent(true)
|
||||
.with_fullsize_content_view(true)
|
||||
.with_title_hidden(true)
|
||||
.with_option_as_alt(OptionAsAlt::OnlyLeft);
|
||||
.with_title_hidden(true);
|
||||
attributes.with_platform_attributes(Box::new(mac_window))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user