-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure OSX EventsLoop to use charactersIgnoringModifiers
in some cases
#351
Comments
Thanks for figuring out what needed to be done here @tmiller! They way platform specific stuff is typically configured is through one of the By the way, is |
Thanks, I'll look to see how
Good question, we may need to check to see if alt is the only modifier being activated.
My current approach is naive and suspect this would break when alt is used with other modifiers. I typically don't use other modifiers with alt. I'll see how it behaves with programs like emacs that use multiple modifiers. |
Tried to update this patch for current master but my attempt doesn't seem to do anything, though I don't see how this would be any different? diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs
index 2b69bfb..0d0b17f 100644
--- a/src/platform_impl/macos/view.rs
+++ b/src/platform_impl/macos/view.rs
@@ -555,7 +555,9 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
let state_ptr: *mut c_void = *this.get_ivar("winitState");
let state = &mut *(state_ptr as *mut ViewState);
let window_id = WindowId(get_window_id(state.ns_window));
- let characters = get_characters(event, false);
+
+ let e_mods = event_mods(event);
+ let characters = get_characters(event, e_mods.alt);
state.raw_characters = Some(characters.clone());
@@ -572,7 +574,7 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
state: ElementState::Pressed,
scancode,
virtual_keycode,
- modifiers: event_mods(event),
+ modifiers: e_mods,
},
is_synthetic: false,
}, |
At the time |
Yeah, I saw that but it's not really a good fix IMO, and should be fixed properly here instead. Some info on what a proper fix should be from someone knowledgeable on the winit project might be helpful. Edit: Also using the following in my Alacritty Cargo.toml to actually test this. [patch."https://github.com/rust-windowing/winit"]
winit = { path = 'winit' } |
This patch works: diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs
index 5da5b536..6826605b 100644
--- a/src/platform_impl/macos/view.rs
+++ b/src/platform_impl/macos/view.rs
@@ -646,7 +646,9 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
let state_ptr: *mut c_void = *this.get_ivar("winitState");
let state = &mut *(state_ptr as *mut ViewState);
let window_id = WindowId(get_window_id(state.ns_window));
- let characters = get_characters(event, false);
+
+ let e_mods = event_mods(event);
+ let characters = get_characters(event, e_mods.alt());
state.raw_characters = Some(characters.clone());
@@ -666,7 +668,7 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
state: ElementState::Pressed,
scancode,
virtual_keycode,
- modifiers: event_mods(event),
+ modifiers: e_mods,
},
is_synthetic: false,
},
@@ -675,7 +677,7 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
let pass_along = {
AppState::queue_event(EventWrapper::StaticEvent(window_event));
// Emit `ReceivedCharacter` for key repeats
- if is_repeat && state.is_key_down {
+ if is_repeat && state.is_key_down || e_mods.alt() {
for character in characters.chars().filter(|c| !is_corporate_character(*c)) {
AppState::queue_event(EventWrapper::StaticEvent(Event::WindowEvent {
window_id, |
This is exposed via the |
I use alacritty as a terminal on OSX, but realized my alt key would not behave correctly. Looking into the issue I ran across this alacritty/alacritty#62. I first modified glutin, then winit to add support using the following patch:
I'd like to make this behavior configurable in some way, but I don't know the best way to go about modifying winit to configure this behavior.
The text was updated successfully, but these errors were encountered: