mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 05:12:55 +00:00
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
88 lines
2 KiB
Text
88 lines
2 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
SubElement := Rectangle {
|
|
property text <=> input.text;
|
|
property <bool> has-focus: input.has-focus;
|
|
forward_focus: input;
|
|
input := TextInput {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
TestCase := Rectangle {
|
|
width: 400phx;
|
|
height: 400phx;
|
|
|
|
callback focus_input1();
|
|
focus_input1 => { input1.focus(); }
|
|
|
|
callback focus_input2();
|
|
focus_input2 => { input2.focus(); }
|
|
|
|
Rectangle {
|
|
input1 := TextInput {
|
|
width: parent.width;
|
|
height: 200phx;
|
|
}
|
|
}
|
|
|
|
input2 := SubElement {
|
|
y: 200phx;
|
|
width: parent.width;
|
|
height: 200phx;
|
|
}
|
|
|
|
if (false) : SubElement { }
|
|
|
|
property<bool> input1_focused: input1.has_focus;
|
|
property<string> input1_text: input1.text;
|
|
property<bool> input2_focused: input2.has_focus;
|
|
property<string> input2_text: input2.text;
|
|
}
|
|
|
|
/*
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert!(!instance.get_input1_focused());
|
|
assert!(!instance.get_input2_focused());
|
|
|
|
instance.invoke_focus_input1();
|
|
assert!(instance.get_input1_focused());
|
|
assert!(!instance.get_input2_focused());
|
|
|
|
instance.invoke_focus_input2();
|
|
assert!(!instance.get_input1_focused());
|
|
assert!(instance.get_input2_focused());
|
|
```
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert(!instance.get_input1_focused());
|
|
assert(!instance.get_input2_focused());
|
|
|
|
instance.invoke_focus_input1();
|
|
assert(instance.get_input1_focused());
|
|
assert(!instance.get_input2_focused());
|
|
|
|
instance.invoke_focus_input2();
|
|
assert(!instance.get_input1_focused());
|
|
assert(instance.get_input2_focused());
|
|
```
|
|
|
|
```js
|
|
var instance = new slint.TestCase();
|
|
assert(!instance.input1_focused);
|
|
assert(!instance.input2_focused);
|
|
|
|
instance.focus_input1();
|
|
assert(instance.input1_focused);
|
|
assert(!instance.input2_focused);
|
|
|
|
instance.focus_input2();
|
|
assert(!instance.input1_focused);
|
|
assert(instance.input2_focused);
|
|
```
|
|
*/
|