| 1 | |
| 2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 4 | |
| 5 | import { AboutSlint, Button } from "std-widgets.slint" ; |
| 6 | |
| 7 | |
| 8 | export global The_Global { |
| 9 | in-out property <string> filename: "foo.txt" ; |
| 10 | } |
| 11 | |
| 12 | export component TestCase inherits Window { |
| 13 | in-out property <string> app_title: "Application" ; |
| 14 | width: 700px; |
| 15 | height: 700px; |
| 16 | //if true : |
| 17 | ContextMenuArea { |
| 18 | Menu { |
| 19 | MenuItem { |
| 20 | title: "Entry1" ; |
| 21 | activated => { debug("Entry1" ); } |
| 22 | } |
| 23 | Menu { |
| 24 | title: "Entry2" ; |
| 25 | MenuItem { |
| 26 | title: "New" ; |
| 27 | activated => { debug("New" ); } |
| 28 | } |
| 29 | if true: Menu { |
| 30 | title: "Open" ; |
| 31 | MenuItem { |
| 32 | title: "Open 1" ; |
| 33 | activated => { debug("1" ); } |
| 34 | } |
| 35 | MenuItem { |
| 36 | title: "Open 2" ; |
| 37 | activated => { debug("2" ); } |
| 38 | } |
| 39 | MenuSeparator {} |
| 40 | for num in 45 : MenuItem { |
| 41 | title: "Open " + (num + 3); |
| 42 | activated => { debug(num+3); } |
| 43 | } |
| 44 | MenuSeparator {} |
| 45 | } |
| 46 | MenuItem { |
| 47 | title: "Save " + The_Global.filename; |
| 48 | |
| 49 | } |
| 50 | if true: MenuSeparator {} |
| 51 | MenuItem { |
| 52 | title: "Exit " + app_title; |
| 53 | activated => { |
| 54 | app_title = "Exited" ; |
| 55 | } |
| 56 | } |
| 57 | MenuItem { |
| 58 | property <physical-length> scale_factor: 25px; |
| 59 | title: "Sacle factor " + scale_factor/1phx; |
| 60 | activated => { |
| 61 | xxx.show(); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // When this focus scope has the focus, the ContextMenu can handle the Menu key |
| 68 | fs := FocusScope {} |
| 69 | } |
| 70 | |
| 71 | xxx := PopupWindow { |
| 72 | Text { text: "Hello" ; } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | out property <bool> test: true; |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | ```rust |
| 81 | let instance = TestCase::new().unwrap(); |
| 82 | assert!(instance.get_test()); |
| 83 | ``` |
| 84 | |
| 85 | ```cpp |
| 86 | auto handle = TestCase::create(); |
| 87 | const TestCase &instance = *handle; |
| 88 | assert(instance.get_test()); |
| 89 | ``` |
| 90 | */ |
| 91 | |