| 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 | export 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 |
| 36 | use slint::{platform::WindowEvent, LogicalPosition}; |
| 37 | use slint::private_unstable_api::re_exports::MouseCursor; |
| 38 | |
| 39 | let instance = TestCase::new().unwrap(); |
| 40 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default); |
| 41 | |
| 42 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) }); |
| 43 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help); |
| 44 | slint_testing::send_mouse_click(&instance, 35., 35.); |
| 45 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default); |
| 46 | |
| 47 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) }); |
| 48 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::NotAllowed); |
| 49 | |
| 50 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(35.0, 35.0) }); |
| 51 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default); |
| 52 | |
| 53 | // Close the popup |
| 54 | |
| 55 | slint_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); |
| 58 | instance.window().dispatch_event(WindowEvent::PointerMoved { position: LogicalPosition::new(135.0, 35.0) }); |
| 59 | assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Help); |
| 60 | ``` |
| 61 | |
| 62 | */ |
| 63 | |