mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00

* Update examples/virtual_keyboard/rust/Cargo.toml Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update internal/core/window.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update internal/core/api.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update internal/core/api.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update internal/core/api.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update internal/core/api.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * code review fixes --------- Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
29 lines
739 B
Rust
29 lines
739 B
Rust
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
|
|
// 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 });
|
|
}
|
|
});
|
|
}
|
|
}
|