Merge pull request #2238 from wash2/modifiers-text
fix: account for modifiers in key text
This commit is contained in:
commit
78dfcfb16a
2 changed files with 36 additions and 11 deletions
|
|
@ -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)
|
- 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)
|
- 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)
|
- 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...
|
Many thanks to...
|
||||||
|
|
||||||
- @PolyMeilex
|
- @PolyMeilex
|
||||||
- @rizzen-yazston
|
- @rizzen-yazston
|
||||||
|
- @wash2
|
||||||
|
|
||||||
## [0.12.0] - 2024-02-15
|
## [0.12.0] - 2024-02-15
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -195,17 +195,40 @@ pub fn window_event(
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
|
||||||
event:
|
let logical_key = {
|
||||||
winit::event::KeyEvent {
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
logical_key,
|
{
|
||||||
state,
|
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
|
||||||
text,
|
event.key_without_modifiers()
|
||||||
location,
|
}
|
||||||
..
|
|
||||||
},
|
#[cfg(target_arch = "wasm32")]
|
||||||
..
|
{
|
||||||
} => Some(Event::Keyboard({
|
// 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 key = key(logical_key);
|
||||||
let modifiers = self::modifiers(modifiers);
|
let modifiers = self::modifiers(modifiers);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue