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
4import { ListView } from "std-widgets.slint";
5
6TestCase := 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
39auto handle = TestCase::create();
40const TestCase &instance = *handle;
41slint_testing::send_mouse_click(&instance, 5., 205.);
42assert_eq(instance.get_value(), "Green");
43```
44
45```rust
46let instance = TestCase::new().unwrap();
47slint_testing::send_mouse_click(&instance, 5., 205.);
48assert_eq!(instance.get_value(), "Green");
49```
50
51```js
52var instance = new slint.TestCase();
53slintlib.private_api.send_mouse_click(instance, 5., 205.);
54assert.equal(instance.value, "Green");
55```
56
57*/
58