mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00

Always use a Pin<Rc> for the component. (This is required to support repeater within repeater as well anyway) Do not use the context within the binding. We can get along by simply capturing a weak pointer to the component
42 lines
1.1 KiB
Text
42 lines
1.1 KiB
Text
TestCase := Rectangle {
|
|
property<bool> condition;
|
|
property<int32> test_value: condition ? 1 : 2;
|
|
property<bool> condition2;
|
|
property<int32> test_value2: condition ? condition2 ? 1 : 2 : condition2 ? 3 : 4;
|
|
|
|
}
|
|
/*
|
|
```cpp
|
|
TestCase instance;
|
|
instance.set_condition(true);
|
|
assert(instance.get_test_value() == 1);
|
|
assert(instance.get_test_value2() == 2);
|
|
instance.set_condition(false);
|
|
assert(instance.get_test_value() == 2);
|
|
assert(instance.get_test_value2() == 4);
|
|
instance.set_condition2(true);
|
|
assert(instance.get_test_value2() == 3);
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new();
|
|
let instance = instance.as_ref();
|
|
instance.set_condition(true);
|
|
assert_eq!(instance.get_test_value(), 1);
|
|
assert_eq!(instance.get_test_value2(), 2);
|
|
instance.set_condition(false);
|
|
assert_eq!(instance.get_test_value(), 2);
|
|
assert_eq!(instance.get_test_value2(), 4);
|
|
instance.set_condition2(true);
|
|
assert_eq!(instance.get_test_value2(), 3);
|
|
```
|
|
|
|
```js
|
|
var instance = new sixtyfps.TestCase({});
|
|
instance.condition = true;
|
|
assert.equal(instance.test_value, 1);
|
|
instance.condition = false;
|
|
assert.equal(instance.test_value, 2);
|
|
```
|
|
*/
|