Skip to content

Commit 2de0e57

Browse files
committed
Interpreter: Register the popup id in the right instance
The instance containing the popup instead of the current instance Fixes #10089
1 parent f009826 commit 2de0e57

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

internal/interpreter/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ fn call_builtin_function(
663663

664664
crate::dynamic_item_tree::show_popup(
665665
popup_window,
666-
component,
666+
enclosing_component,
667667
popup,
668668
|instance_ref| {
669669
let comp = ComponentInstance::InstanceRef(instance_ref);

tests/cases/elements/popupwindow_close_policy.slint

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ export component TestCase {
114114
}
115115
}
116116
}
117+
118+
// ISSUE #10089
119+
if true : TouchArea {
120+
x: 250px;
121+
y: 140px;
122+
width: 3px;
123+
height: 3px;
124+
clicked => {
125+
self-closing-popup.show();
126+
}
127+
}
117128
}
118129
/*
119130
@@ -280,6 +291,22 @@ slint_testing::send_keyboard_string_sequence(&instance, "\u{001b}");
280291
slint_testing::send_mouse_click(&instance, 15., 15.);
281292
assert_eq!(instance.get_click_count(), 2);
282293
294+
// -- ISSUE #10089
295+
instance.set_popup_created(false);
296+
instance.set_click_count(0);
297+
instance.set_popup_clicked(0);
298+
slint_testing::send_mouse_click(&instance, 251., 141.);
299+
assert_eq!(instance.get_click_count(), 0);
300+
assert_eq!(instance.get_popup_created(), true);
301+
assert_eq!(instance.get_popup_clicked(), 0);
302+
303+
// Click on the popup, should close it()
304+
slint_testing::send_mouse_click(&instance, 15., 15.);
305+
assert_eq!(instance.get_click_count(), 0);
306+
307+
// Subsequent click to verify that it was closed
308+
slint_testing::send_mouse_click(&instance, 15., 15.);
309+
assert_eq!(instance.get_click_count(), 1);
283310
```
284311
285312
```cpp
@@ -440,6 +467,24 @@ assert_eq(instance.get_popup_clicked(), 2005);
440467
slint_testing::send_keyboard_string_sequence(&instance, "\u001b");
441468
slint_testing::send_mouse_click(&instance, 15., 15.);
442469
assert_eq(instance.get_click_count(), 2);
470+
471+
// -- ISSUE #10089
472+
instance.set_popup_created(false);
473+
instance.set_click_count(0);
474+
instance.set_popup_clicked(0);
475+
slint_testing::send_mouse_click(&instance, 251., 141.);
476+
assert_eq(instance.get_click_count(), 0);
477+
assert_eq(instance.get_popup_created(), true);
478+
assert_eq(instance.get_popup_clicked(), 0);
479+
480+
// Click on the popup, should close it()
481+
slint_testing::send_mouse_click(&instance, 15., 15.);
482+
assert_eq(instance.get_click_count(), 0);
483+
484+
// Subsequent click to verify that it was closed
485+
slint_testing::send_mouse_click(&instance, 15., 15.);
486+
assert_eq(instance.get_click_count(), 1);
487+
443488
```
444489
445490
```js
@@ -527,6 +572,23 @@ assert.equal(instance.popup_clicked, 2005);
527572
slintlib.private_api.send_keyboard_string_sequence(instance, "\u{001b}");
528573
slintlib.private_api.send_mouse_click(instance, 15., 15.);
529574
assert.equal(instance.click_count, 2);
575+
576+
// -- ISSUE #10089
577+
instance.popup_created = false;
578+
instance.click_count = 0;
579+
instance.popup_clicked = 0;
580+
slintlib.private_api.send_mouse_click(instance, 251., 141.);
581+
assert.equal(instance.click_count, 0);
582+
assert.equal(instance.popup_created, true);
583+
assert.equal(instance.popup_clicked, 0);
584+
585+
// Click on the popup, should close it()
586+
slintlib.private_api.send_mouse_click(instance, 15., 15.);
587+
assert.equal(instance.click_count, 0);
588+
589+
// Subsequent click to verify that it was closed
590+
slintlib.private_api.send_mouse_click(instance, 15., 15.);
591+
assert.equal(instance.click_count, 1);
530592
```
531593
532594
*/

0 commit comments

Comments
 (0)