| 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 | export 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 |
| 36 | auto handle = TestCase::create(); |
| 37 | const TestCase &instance = *handle; |
| 38 | slint_testing::send_mouse_click(&instance, 90., 90.); |
| 39 | assert_eq(instance.get_clicked(), 0); |
| 40 | slint_testing::send_mouse_click(&instance, 90., 90.); |
| 41 | assert_eq(instance.get_clicked(), 1); |
| 42 | ``` |
| 43 | |
| 44 | ```rust |
| 45 | let instance = TestCase::new().unwrap(); |
| 46 | slint_testing::send_mouse_click(&instance, 90., 90.); |
| 47 | assert_eq!(instance.get_clicked(), 0); |
| 48 | slint_testing::send_mouse_click(&instance, 90., 90.); |
| 49 | assert_eq!(instance.get_clicked(), 1); |
| 50 | ``` |
| 51 | |
| 52 | ```js |
| 53 | var instance = new slint.TestCase(); |
| 54 | slintlib.private_api.send_mouse_click(instance, 90., 90.); |
| 55 | assert.equal(instance.clicked, 0); |
| 56 | slintlib.private_api.send_mouse_click(instance, 90., 90.); |
| 57 | assert.equal(instance.clicked, 1); |
| 58 | ``` |
| 59 | |
| 60 | */ |
| 61 | |