1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { LineEdit, Button } from "std-widgets.slint";
5
6import { VirtualKeyboardHandler, VirtualKeyboard, KeyModel } from "virtual_keyboard.slint";
7
8export { VirtualKeyboardHandler, KeyModel }
9
10export component MainWindow inherits Window {
11 title: "Virtual Keyboard example";
12 width: 600px;
13 height: 400px;
14
15 Rectangle {
16 VerticalLayout {
17 alignment: start;
18 padding: 16px;
19 spacing: 8px;
20
21 Text {
22 text: "Focus to open keyboard";
23 horizontal-alignment: left;
24 }
25 LineEdit {}
26
27 Text {
28 text: "Focus to open keyboard";
29 horizontal-alignment: left;
30 }
31
32 LineEdit {}
33
34 HorizontalLayout {
35 alignment: start;
36
37 Button {
38 text: self.checked ? "Click to close keyboard" : "Click to open keyboard";
39 checked: TextInputInterface.text-input-focused;
40
41 clicked => {
42 TextInputInterface.text-input-focused = !TextInputInterface.text-input-focused;
43
44 }
45 }
46 }
47 }
48
49 keyboard := VirtualKeyboard {
50 y: TextInputInterface.text-input-focused ? parent.height - self.height : parent.height;
51 }
52 }
53}