Simplify KeyEvent

Fold CharacterInput into KeyPressed/KeyReleased and store the "key" as a string.

Also, instead of exposing the KeyCode we're encoding special characters
into the string.
This commit is contained in:
Simon Hausmann 2021-01-21 15:37:17 +01:00
parent db740831ee
commit 9ca87ab312
10 changed files with 223 additions and 463 deletions

View file

@ -198,9 +198,9 @@ pub mod re_exports {
PathArcTo, PathData, PathElement, PathEvent, PathLineTo, Point, Rect, Size,
};
pub use sixtyfps_corelib::input::{
FocusEvent, InputEventResult, KeyCode, KeyEvent, KeyEventResult, KeyboardModifiers,
MouseEvent, ALT_MODIFIER, CONTROL_MODIFIER, COPY_PASTE_MODIFIER, LOGO_MODIFIER,
NO_MODIFIER, SHIFT_MODIFIER,
FocusEvent, InputEventResult, KeyEvent, KeyEventResult, KeyboardModifiers, MouseEvent,
ALT_MODIFIER, CONTROL_MODIFIER, COPY_PASTE_MODIFIER, LOGO_MODIFIER, NO_MODIFIER,
SHIFT_MODIFIER,
};
pub use sixtyfps_corelib::item_tree::{
item_offset, visit_item_tree, ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable,
@ -322,22 +322,6 @@ pub mod testing {
KEYBOARD_MODIFIERS.with(|x| x.set(modifiers))
}
/// Simulate a series of key press and release event
pub fn send_key_clicks<
X: vtable::HasStaticVTable<sixtyfps_corelib::component::ComponentVTable> + HasWindow,
Component: Into<vtable::VRc<sixtyfps_corelib::component::ComponentVTable, X>> + Clone,
>(
component: &Component,
key_codes: &[crate::re_exports::KeyCode],
) {
let component = component.clone().into();
sixtyfps_corelib::tests::sixtyfps_send_key_clicks(
&crate::re_exports::Slice::from_slice(key_codes),
KEYBOARD_MODIFIERS.with(|x| x.get()),
component.component_window(),
)
}
/// Simulate entering a sequence of ascii characters key by key.
pub fn send_keyboard_string_sequence<
X: vtable::HasStaticVTable<sixtyfps_corelib::component::ComponentVTable> + HasWindow,