1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4// Verify that two repeaters (if and for) are placed correctly in the item tree
5// and matched in the dyn_visit closure.
6// The two repeaters ended up being swapped and sub-component's repeater was
7// visited when the Text's child's repeater should have been, resulting in
8// wrong rendering order. This is tested by clicking into the left half and
9// verifying that it did not hit the sub-component's repeater.
10
11SubCompo := Rectangle {
12 property <bool> clicked: false;
13 for x in 1: Text {
14 text: "I should appear in the right half";
15 ta := TouchArea {
16 clicked => {
17 root.clicked = true;
18 }
19 }
20 }
21}
22
23TestCase := Rectangle {
24 width: 300phx;
25 height: 300phx;
26 property clicked <=> c.clicked;
27 Text {
28 if (false): TouchArea {
29 }
30 }
31 c := SubCompo {
32 x: 200px;
33 }
34}
35
36/*
37```rust
38let instance = TestCase::new().unwrap();
39
40assert!(!instance.get_clicked());
41slint_testing::send_mouse_click(&instance, 20., 5.);
42assert!(!instance.get_clicked());
43```
44
45```cpp
46auto handle = TestCase::create();
47const TestCase &instance = *handle;
48assert(!instance.get_clicked());
49slint_testing::send_mouse_click(&instance, 20., 5.);
50assert(!instance.get_clicked());
51```
52
53
54```js
55var instance = new slint.TestCase({});
56assert(!instance.clicked);
57slintlib.private_api.send_mouse_click(instance, 20., 5.);
58assert(!instance.clicked);
59```
60
61
62*/
63