-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix closing PopupWindow when the click opens another PopupWindow
Fix #7322
- Loading branch information
Showing
3 changed files
with
158 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
tests/cases/elements/popupwindow_nested_close-on-click.slint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
// https://github.com/slint-ui/slint/issues/7322 | ||
// A PopupWindow with the default close-on-click policy should close when clicked, even if the click open a nested popup | ||
|
||
export component TestCase { | ||
width: 300px; | ||
height: 300px; | ||
|
||
in-out property <int> popup1-clicked; | ||
in-out property <int> popup2-clicked; | ||
in-out property <int> root-clicked; | ||
|
||
popup1 := PopupWindow { | ||
Rectangle { | ||
background: yellow; | ||
} | ||
|
||
x: 10px; | ||
y: 10px; | ||
height: 50px; | ||
width: 50px; | ||
|
||
TouchArea { | ||
clicked => { | ||
popup1-clicked += 1; | ||
popup2.show(); | ||
} | ||
} | ||
} | ||
|
||
popup2 := PopupWindow { | ||
Rectangle { | ||
background: red; | ||
} | ||
|
||
x: 40px; | ||
y: 40px; | ||
height: 50px; | ||
width: 50px; | ||
|
||
TouchArea { | ||
clicked => { | ||
popup2-clicked += 1; | ||
} | ||
} | ||
} | ||
|
||
TouchArea { | ||
clicked => { | ||
root-clicked += 1; | ||
popup1.show(); | ||
} | ||
} | ||
} | ||
|
||
/* | ||
```rust | ||
let instance = TestCase::new().unwrap(); | ||
slint_testing::send_mouse_click(&instance, 15., 15.); | ||
assert_eq!(instance.get_root_clicked(), 1); | ||
assert_eq!(instance.get_popup1_clicked(), 0); | ||
assert_eq!(instance.get_popup2_clicked(), 0); | ||
// popup1 is open | ||
slint_testing::send_mouse_click(&instance, 15., 15.); | ||
assert_eq!(instance.get_root_clicked(), 1); | ||
assert_eq!(instance.get_popup1_clicked(), 1); | ||
assert_eq!(instance.get_popup2_clicked(), 0); | ||
// popup2 is open, popup1 is closed | ||
slint_testing::send_mouse_click(&instance, 45., 45.); | ||
assert_eq!(instance.get_root_clicked(), 1); | ||
assert_eq!(instance.get_popup1_clicked(), 1); | ||
assert_eq!(instance.get_popup2_clicked(), 1); | ||
// all popup closed | ||
slint_testing::send_mouse_click(&instance, 45., 45.); | ||
assert_eq!(instance.get_root_clicked(), 2); | ||
assert_eq!(instance.get_popup1_clicked(), 1); | ||
assert_eq!(instance.get_popup2_clicked(), 1); | ||
// popup1 is open | ||
// click where popup2 will be | ||
slint_testing::send_mouse_click(&instance, 45., 45.); | ||
assert_eq!(instance.get_root_clicked(), 2); | ||
assert_eq!(instance.get_popup1_clicked(), 2); | ||
assert_eq!(instance.get_popup2_clicked(), 1); | ||
// popup2 is open, popup1 is closed | ||
slint_testing::send_mouse_click(&instance, 45., 45.); | ||
assert_eq!(instance.get_root_clicked(), 2); | ||
assert_eq!(instance.get_popup1_clicked(), 2); | ||
assert_eq!(instance.get_popup2_clicked(), 2); | ||
// all popup closed | ||
slint_testing::send_mouse_click(&instance, 45., 45.); | ||
assert_eq!(instance.get_root_clicked(), 3); | ||
assert_eq!(instance.get_popup1_clicked(), 2); | ||
assert_eq!(instance.get_popup2_clicked(), 2); | ||
``` | ||
*/ |