| 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 { |
| 5 | width: 100px; |
| 6 | height: 100px; |
| 7 | out property <string> clicked_value; |
| 8 | l := VerticalLayout { |
| 9 | for val[i] in [10,20,30] : TouchArea { |
| 10 | // issue 4961 was about index, but also add other names that are comonly used |
| 11 | property <string> index: "index" + i; |
| 12 | property <string> model-data: "model-data" + val; |
| 13 | property <string> model: "model" + val; |
| 14 | property <string> value: "value" + val; |
| 15 | property <string> idx: "idx" +i; |
| 16 | txt := Text { text: index+model-data+model+value+idx; } |
| 17 | clicked => { clicked_value = txt.text; } |
| 18 | height: txt.text != "" ? val*1px : 0px; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | out property <bool> test: l.preferred-height == 10px+20px+30px; |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | ```cpp |
| 27 | auto handle = TestCase::create(); |
| 28 | const TestCase &instance = *handle; |
| 29 | |
| 30 | assert(instance.get_test()); |
| 31 | |
| 32 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 33 | assert_eq(instance.get_clicked_value(), "index0model-data10model10value10idx0"); |
| 34 | |
| 35 | |
| 36 | ``` |
| 37 | |
| 38 | |
| 39 | ```rust |
| 40 | let instance = TestCase::new().unwrap(); |
| 41 | assert!(instance.get_test()); |
| 42 | |
| 43 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 44 | assert_eq!(instance.get_clicked_value(), "index0model-data10model10value10idx0"); |
| 45 | |
| 46 | ``` |
| 47 | |
| 48 | ```js |
| 49 | var instance = new slint.TestCase(); |
| 50 | assert(instance.test); |
| 51 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
| 52 | assert.equal(instance.clicked_value, "index0model-data10model10value10idx0"); |
| 53 | ``` |
| 54 | */ |
| 55 | |