mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Add support for dispatching key events through the public platform API
This change adds `KeyPress` and `KeyRelease` variants to the `WindowEvent` enum, along with the new `slint::Key` enum, that allows encoding keys.
This commit is contained in:
parent
e3838543fe
commit
61c39b5fa1
36 changed files with 681 additions and 315 deletions
|
@ -1005,15 +1005,25 @@ namespace slint::testing {
|
|||
|
||||
using cbindgen_private::KeyboardModifiers;
|
||||
|
||||
/// Send a key events to the given component instance
|
||||
inline void send_keyboard_char(const slint::interpreter::ComponentInstance *component,
|
||||
const slint::SharedString &str, bool pressed)
|
||||
{
|
||||
const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
|
||||
cbindgen_private::slint_interpreter_component_instance_window(
|
||||
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
|
||||
cbindgen_private::slint_send_keyboard_char(
|
||||
&str, pressed, reinterpret_cast<const cbindgen_private::WindowAdapterRc *>(win_ptr));
|
||||
}
|
||||
|
||||
/// Send a key events to the given component instance
|
||||
inline void send_keyboard_string_sequence(const slint::interpreter::ComponentInstance *component,
|
||||
const slint::SharedString &str,
|
||||
KeyboardModifiers modifiers = {})
|
||||
const slint::SharedString &str)
|
||||
{
|
||||
const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
|
||||
cbindgen_private::slint_interpreter_component_instance_window(
|
||||
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
|
||||
cbindgen_private::send_keyboard_string_sequence(
|
||||
&str, modifiers, reinterpret_cast<const cbindgen_private::WindowAdapterRc *>(win_ptr));
|
||||
&str, reinterpret_cast<const cbindgen_private::WindowAdapterRc *>(win_ptr));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue