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
4export component TestCase inherits Window {
5 height: 100px;
6 width: 100px;
7 out property <int> clicked;
8 GridLayout {
9 Row {
10 popup2 := PopupWindow {
11 Rectangle {
12 background: yellow;
13 TouchArea {
14 clicked => { root.clicked += 1; }
15 }
16 }
17
18 // that's 20px relative to the Row which will be a 0x0 Empty centered in the window
19 x: 20px;
20 y: 20px;
21 height: 50px;
22 width: 50px;
23 }
24
25 ta := TouchArea {
26 clicked => {
27 popup2.show();
28 }
29 }
30 }
31 }
32}
33
34/*
35```cpp
36auto handle = TestCase::create();
37const TestCase &instance = *handle;
38slint_testing::send_mouse_click(&instance, 90., 90.);
39assert_eq(instance.get_clicked(), 0);
40slint_testing::send_mouse_click(&instance, 90., 90.);
41assert_eq(instance.get_clicked(), 1);
42```
43
44```rust
45let instance = TestCase::new().unwrap();
46slint_testing::send_mouse_click(&instance, 90., 90.);
47assert_eq!(instance.get_clicked(), 0);
48slint_testing::send_mouse_click(&instance, 90., 90.);
49assert_eq!(instance.get_clicked(), 1);
50```
51
52```js
53var instance = new slint.TestCase();
54slintlib.private_api.send_mouse_click(instance, 90., 90.);
55assert.equal(instance.clicked, 0);
56slintlib.private_api.send_mouse_click(instance, 90., 90.);
57assert.equal(instance.clicked, 1);
58```
59
60*/
61