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
4export component TestCase {
5 width: 300px;
6 height: 300px;
7
8 popup := PopupWindow {
9 x: 100px;
10 y: 10px;
11 width: 100px;
12 height: parent.height - 20px;
13 Rectangle { background: blue; }
14 TouchArea {
15 y: 0px; x: 0px;
16 height: 50px;
17 width: 50px;
18 mouse-cursor: not-allowed;
19 }
20 }
21
22 TouchArea {
23 mouse-cursor: help;
24 x: 0px;
25 width: 150px;
26 clicked => {
27 popup.show()
28 }
29
30 }
31
32}
33/*
34
35```rust
36use slint::{platform::WindowEvent, LogicalPosition};
37use slint::private_unstable_api::re_exports::MouseCursor;
38
39let instance = TestCase::new().unwrap();
40assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
41
42instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
43assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
44slint_testing::send_mouse_click(&instance, 35., 35.);
45assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
46
47instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
48assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::NotAllowed);
49
50instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) });
51assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
52
53// Close the popup
54
55slint_testing::send_mouse_click(&instance, 135., 35.);
56// FIXME: it takes two events to get that correctly
57// assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
58instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) });
59assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help);
60```
61
62*/
63