forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
32 lines (26 loc) · 901 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
slint::include_modules!();
pub fn main() {
let main_window = MainWindow::new().unwrap();
virtual_keyboard::init(&main_window);
main_window.run().unwrap();
}
mod virtual_keyboard {
use super::*;
use slint::*;
pub fn init(app: &MainWindow) {
let weak = app.as_weak();
app.global::<VirtualKeyboardHandler>().on_key_pressed({
let weak = weak.clone();
move |key| {
weak.unwrap()
.window()
.dispatch_event(slint::platform::WindowEvent::KeyPressed { text: key.clone() });
weak.unwrap()
.window()
.dispatch_event(slint::platform::WindowEvent::KeyReleased { text: key });
}
});
}
}