Allow to simulate key event with the interpreter (C++)

This commit is contained in:
Olivier Goffart 2021-06-11 11:21:09 +02:00
parent 7f9bb18b9a
commit 7b63bb7d65
2 changed files with 41 additions and 1 deletions

View file

@ -836,3 +836,18 @@ public:
};
}
namespace sixtyfps::testing {
/// Send a key events to the given component instance
inline void send_keyboard_string_sequence(const sixtyfps::interpreter::ComponentInstance *component,
const sixtyfps::SharedString &str,
KeyboardModifiers modifiers = {})
{
cbindgen_private::ComponentWindowOpaque win;
cbindgen_private::sixtyfps_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win);
cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<cbindgen_private::ComponentWindow *>(&win));
cbindgen_private::sixtyfps_component_window_drop(&win);
}
}