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
8import { SpinBox } from "std-widgets.slint";
9export 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
22use slint::platform::Key;
23use std::cell::RefCell;
24use std::rc::Rc;
25
26let instance = TestCase::new().unwrap();
27slint_testing::send_mouse_click(&instance, 5., 5.);
28assert!(instance.get_spinbox_focused());
29
30let edits = Rc::new(RefCell::new(Vec::new()));
31
32instance.on_edited({
33 let edits = edits.clone();
34 move |val| {
35 edits.borrow_mut().push(val);
36}});
37
38slint_testing::send_keyboard_char(&instance, '4', true);
39slint_testing::send_keyboard_char(&instance, Key::Return.into(), true);
40
41assert_eq!(edits.borrow().clone(), vec![40]);
42
43```
44
45*/
46