| 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 | import { Button } from "std-widgets.slint" ; |
| 5 | |
| 6 | TestCase := Rectangle { |
| 7 | property <bool> checked <=> tb.checked; |
| 8 | |
| 9 | tb := Button { |
| 10 | width: 100px; |
| 11 | height: 100px; |
| 12 | |
| 13 | checkable: true; |
| 14 | checked: true; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /* |
| 19 | ```cpp |
| 20 | auto handle = TestCase::create(); |
| 21 | const TestCase &instance = *handle; |
| 22 | assert(instance.get_checked()); |
| 23 | |
| 24 | // click on button |
| 25 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 26 | assert(!instance.get_checked()); |
| 27 | |
| 28 | // click on button again |
| 29 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 30 | assert(instance.get_checked()); |
| 31 | |
| 32 | ``` |
| 33 | |
| 34 | |
| 35 | ```rust |
| 36 | let instance = TestCase::new().unwrap(); |
| 37 | assert!(instance.get_checked()); |
| 38 | |
| 39 | // click on button |
| 40 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 41 | assert!(!instance.get_checked()); |
| 42 | |
| 43 | // click on button again |
| 44 | slint_testing::send_mouse_click(&instance, 50., 50.); |
| 45 | assert!(instance.get_checked()); |
| 46 | |
| 47 | ``` |
| 48 | |
| 49 | ```js |
| 50 | var instance = new slint.TestCase(); |
| 51 | assert.equal(instance.checked, true); |
| 52 | |
| 53 | // click on button |
| 54 | slintlib.private_api.send_mouse_click(instance, 50., 50.); |
| 55 | assert.equal(instance.checked, false); |
| 56 | |
| 57 | // click on button |
| 58 | slintlib.private_api.send_mouse_click(instance, 50., 50.); |
| 59 | assert.equal(instance.checked, true); |
| 60 | ``` |
| 61 | */ |
| 62 | |