1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4slint::include_modules!();
5
6pub fn main() {
7 let main_window: MainWindow = MainWindow::new().unwrap();
8
9 virtual_keyboard::init(&main_window);
10
11 main_window.run().unwrap();
12}
13
14mod virtual_keyboard {
15 use super::*;
16 use slint::*;
17
18 pub fn init(app: &MainWindow) {
19 let weak: Weak = app.as_weak();
20 app.global::<VirtualKeyboardHandler>().on_key_pressed({
21 move |key: SharedString| {
22 weak&Window.unwrap()
23 .window()
24 .dispatch_event(slint::platform::WindowEvent::KeyPressed { text: key.clone() });
25 weak&Window.unwrap()
26 .window()
27 .dispatch_event(slint::platform::WindowEvent::KeyReleased { text: key });
28 }
29 });
30 }
31}
32