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 | |
5 | // FIXME: Ignore the SpinBox test with the Qt style because it doesn't support editing (#4690) |
6 | //ignore: style-qt |
7 | |
8 | import { SpinBox } from "std-widgets.slint" ; |
9 | export component TestCase inherits Window { |
10 | width: 100px; |
11 | height: 100px; |
12 | box := SpinBox {} |
13 | forward-focus: box; |
14 | out property <bool> spinbox-focused <=> box.has_focus; |
15 | callback edited <=> box.edited; |
16 | } |
17 | |
18 | /* |
19 | |
20 | |
21 | ```rust |
22 | use slint::platform::Key; |
23 | use std::cell::RefCell; |
24 | use std::rc::Rc; |
25 | |
26 | let instance = TestCase::new().unwrap(); |
27 | slint_testing::send_mouse_click(&instance, 5., 5.); |
28 | assert!(instance.get_spinbox_focused()); |
29 | |
30 | let edits = Rc::new(RefCell::new(Vec::new())); |
31 | |
32 | instance.on_edited({ |
33 | let edits = edits.clone(); |
34 | move |val| { |
35 | edits.borrow_mut().push(val); |
36 | }}); |
37 | |
38 | slint_testing::send_keyboard_char(&instance, '4', true); |
39 | slint_testing::send_keyboard_char(&instance, Key::Return.into(), true); |
40 | |
41 | assert_eq!(edits.borrow().clone(), vec![40]); |
42 | |
43 | ``` |
44 | |
45 | */ |
46 | |