From 9600954d8de57442dfe1269dcf80e3d23edbaf0a Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 5 Feb 2024 14:54:18 -0500 Subject: Decouple `Key` from modifiers and apply them to `text` --- winit/src/conversion.rs | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 478dbddd..3d2ba0a4 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -195,17 +195,40 @@ pub fn window_event( })) } }, - WindowEvent::KeyboardInput { - event: - winit::event::KeyEvent { - logical_key, - state, - text, - location, - .. - }, - .. - } => Some(Event::Keyboard({ + WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({ + let logical_key = { + #[cfg(not(target_arch = "wasm32"))] + { + use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; + event.key_without_modifiers() + } + + #[cfg(target_arch = "wasm32")] + { + // TODO: Fix inconsistent API on Wasm + event.logical_key + } + }; + + let text = { + #[cfg(not(target_arch = "wasm32"))] + { + use crate::core::SmolStr; + use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; + + event.text_with_all_modifiers().map(SmolStr::new) + } + + #[cfg(target_arch = "wasm32")] + { + // TODO: Fix inconsistent API on Wasm + event.text + } + }; + + let winit::event::KeyEvent { + state, location, .. + } = event; let key = key(logical_key); let modifiers = self::modifiers(modifiers); -- cgit From 4aaa4f2e20cd581827cdb459af54983ff0a41546 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 20 Feb 2024 16:32:15 +0100 Subject: Update `CHANGELOG` --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a082a568..bb04a8fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Black images when using OpenGL backend in `iced_wgpu`. [#2259](https://github.com/iced-rs/iced/pull/2259) - Documentation for `horizontal_space` and `vertical_space` helpers. [#2265](https://github.com/iced-rs/iced/pull/2265) - WebAssembly platform. [#2271](https://github.com/iced-rs/iced/pull/2271) +- Decouple `Key` from `keyboard::Modifiers` and apply them to `text` in `KeyboardInput`. [#2238](https://github.com/iced-rs/iced/pull/2238) Many thanks to... - @PolyMeilex - @rizzen-yazston +- @wash2 ## [0.12.0] - 2024-02-15 ### Added -- cgit