| 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 | // Allow for accessing built-in functions on root elements even with an injected window item |
| 5 | |
| 6 | export component TestCase inherits TextInput { |
| 7 | width: 100phx; |
| 8 | height: 100phx; |
| 9 | |
| 10 | out property<bool> selection-set; |
| 11 | |
| 12 | text: "Hello World" ; |
| 13 | if (true): TouchArea { |
| 14 | clicked => { |
| 15 | root.select-all(); |
| 16 | root.selection-set = root.anchor-position-byte-offset == 0 && root.cursor-position-byte-offset == 11; |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | /* |
| 22 | |
| 23 | ```cpp |
| 24 | auto handle = TestCase::create(); |
| 25 | const TestCase &instance = *handle; |
| 26 | assert(!instance.get_selection_set()); |
| 27 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 28 | assert(instance.get_selection_set()); |
| 29 | ``` |
| 30 | |
| 31 | ```rust |
| 32 | let instance = TestCase::new().unwrap(); |
| 33 | assert!(!instance.get_selection_set()); |
| 34 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 35 | assert!(instance.get_selection_set()); |
| 36 | ``` |
| 37 | |
| 38 | ```js |
| 39 | var instance = new slint.TestCase(); |
| 40 | assert(!instance.selection_set); |
| 41 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
| 42 | assert(instance.selection_set); |
| 43 | ``` |
| 44 | */ |
| 45 | |