1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | import { ListView } from "std-widgets.slint" ; |
5 | |
6 | TestCase := Window { |
7 | width: 400px; |
8 | height: 540px; |
9 | |
10 | property <string> value; |
11 | |
12 | listview := ListView { |
13 | for data in [ |
14 | { text: "Blue" , color: #0000ff, bg: #eeeeee}, |
15 | { text: "Red" , color: #ff0000, bg: #eeeeee}, |
16 | { text: "Green" , color: #00ff00, bg: #eeeeee}, |
17 | { text: "Yellow" , color: #ffff00, bg: #222222 }, |
18 | { text: "Black" , color: #000000, bg: #eeeeee }, |
19 | { text: "White" , color: #ffffff, bg: #222222 }, |
20 | { text: "Magenta" , color: #ff00ff, bg: #eeeeee }, |
21 | { text: "Cyan" , color: #00ffff, bg: #222222 }, |
22 | ] : delegate := Rectangle { |
23 | background: @linear-gradient(90deg, data.bg,data.bg.brighter(0.5)); |
24 | HorizontalLayout { |
25 | text_Name := Text { |
26 | height: 100px; |
27 | text: data.text; |
28 | color: data.color; |
29 | font_size: 20px ; |
30 | } |
31 | } |
32 | TouchArea { clicked => { value = data.text; } } |
33 | } |
34 | } |
35 | } |
36 | |
37 | /* |
38 | ```cpp |
39 | auto handle = TestCase::create(); |
40 | const TestCase &instance = *handle; |
41 | slint_testing::send_mouse_click(&instance, 5., 205.); |
42 | assert_eq(instance.get_value(), "Green"); |
43 | ``` |
44 | |
45 | ```rust |
46 | let instance = TestCase::new().unwrap(); |
47 | slint_testing::send_mouse_click(&instance, 5., 205.); |
48 | assert_eq!(instance.get_value(), "Green"); |
49 | ``` |
50 | |
51 | ```js |
52 | var instance = new slint.TestCase(); |
53 | slintlib.private_api.send_mouse_click(instance, 5., 205.); |
54 | assert.equal(instance.value, "Green"); |
55 | ``` |
56 | |
57 | */ |
58 | |