slint/tests/cases/examples/key_press.60
2021-08-17 22:38:16 +02:00

39 lines
1.3 KiB
Text

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
W := Window {
VerticalLayout {
Rectangle { background: field.has_focus ? blue: red; }
field := FocusScope {
vertical_stretch: 1;
key-pressed(event) => {
if (event.modifiers.control) {
debug(" (control modifier pressed)");
}
if (event.modifiers.alt) {
debug(" (alt modifier pressed)");
}
if (event.modifiers.shift) {
debug(" (shift modifier pressed)");
}
if (event.modifiers.meta) {
debug(" (meta modifier pressed)");
}
debug(event.text);
t.text += event.text;
accept
}
Rectangle { background: yellow; }
}
t:= Text {
text: "> ";
}
}
}