forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
They are model and if the model is copied, the changes in model need to apply to all copies. Fixes slint-ui#5249
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// 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); | ||
``` | ||
*/ |