mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
They are model and if the model is copied, the changes in model need to apply to all copies. Fixes #5249
61 lines
1.2 KiB
Text
61 lines
1.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
|
|
|
|
component IndirectChange {
|
|
in property <[int]> mod;
|
|
property <[int]> private: mod;
|
|
|
|
init => {
|
|
private[0] += 1;
|
|
}
|
|
}
|
|
|
|
export component TestCase {
|
|
|
|
property <[int]> m1: [5];
|
|
property <[int]> m2: [8];
|
|
property <[int]> indirect: m2;
|
|
|
|
public function up() {
|
|
indirect[0] += 10;
|
|
}
|
|
|
|
callback up2();
|
|
up2 => {up()}
|
|
|
|
IndirectChange { mod: m1; }
|
|
|
|
out property <int> t1: m1[0];
|
|
out property <int> t2: m2[0];
|
|
|
|
out property <bool> test: t1 == 5+1 && t2 == 8;
|
|
}
|
|
|
|
/*
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert_eq(instance.get_t1(), 6);
|
|
assert(instance.get_test());
|
|
instance.invoke_up();
|
|
assert_eq(instance.get_t2(), 18);
|
|
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert_eq!(instance.get_t1(), 6);
|
|
assert!(instance.get_test());
|
|
instance.invoke_up();
|
|
assert_eq!(instance.get_t2(), 18);
|
|
```
|
|
|
|
```js
|
|
var instance = new slint.TestCase({});
|
|
assert.equal(instance.t1, 6);
|
|
assert(instance.test);
|
|
instance.up2();
|
|
assert.equal(instance.t2, 18);
|
|
```
|
|
*/
|