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 { StandardTableView } from "std-widgets.slint" ; |
5 | |
6 | TestCase := Rectangle { |
7 | callback set-current-row(int); |
8 | |
9 | out property <int> row-count: list.rows.length; |
10 | out property <int> callback-current-row: -1; |
11 | |
12 | in-out property<[[StandardListViewItem]]> rows: [ |
13 | [{ text: "Item 1" }, { text: "Description" } ], |
14 | [{ text: "Item 1" }, { text: "Description" }], |
15 | [{ text: "Item 1" }, { text: "Description" }], |
16 | ]; |
17 | in-out property <int> current-row <=> list.current-row; |
18 | |
19 | list := StandardTableView { |
20 | rows: root.rows; |
21 | |
22 | columns: [ |
23 | { title: "Items" }, |
24 | { title: "Descriptions" }, |
25 | ]; |
26 | |
27 | current-row-changed(index) => { |
28 | root.callback-current-row = index; |
29 | } |
30 | } |
31 | |
32 | set-current-row(index) => { |
33 | list.set-current-row(index); |
34 | } |
35 | } |
36 | |
37 | /* |
38 | |
39 | ```rust |
40 | let instance = TestCase::new().unwrap(); |
41 | assert_eq!(instance.get_row_count(), 3); |
42 | assert_eq!(instance.get_current_row(), -1); |
43 | |
44 | assert_eq!(instance.get_callback_current_row(), -1); |
45 | instance.invoke_set_current_row(1); |
46 | assert_eq!(instance.get_callback_current_row(), 1); |
47 | assert_eq!(instance.get_current_row(), 1); |
48 | ``` |
49 | */ |