Decouple Key from modifiers and apply them to text
This commit is contained in:
parent
e24b1b6500
commit
9600954d8d
1 changed files with 34 additions and 11 deletions
|
|
@ -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