mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-21 15:52:19 +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
|
@ -478,7 +478,9 @@ SCENARIO("Send key events")
|
|||
property <string> result;
|
||||
scope := FocusScope {
|
||||
key-pressed(event) => {
|
||||
result += event.text;
|
||||
if (event.text != Key.Shift && event.text != Key.Control) {
|
||||
result += event.text;
|
||||
}
|
||||
return accept;
|
||||
}
|
||||
}
|
||||
|
@ -487,7 +489,7 @@ SCENARIO("Send key events")
|
|||
"");
|
||||
REQUIRE(comp_def.has_value());
|
||||
auto instance = comp_def->create();
|
||||
slint::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
|
||||
slint::testing::send_keyboard_string_sequence(&*instance, "Hello keys!");
|
||||
REQUIRE(*instance->get_property("result")->to_string() == "Hello keys!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue