fix: do not allow cursor or keyboard activity when popup is open
traps Tab from escaping, and won't allow elements in the background to react to hover
This commit is contained in:
parent
9aa87cd66b
commit
1f87cbc883
1 changed files with 18 additions and 2 deletions
|
|
@ -138,6 +138,10 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn Operation,
|
operation: &mut dyn Operation,
|
||||||
) {
|
) {
|
||||||
|
// Skip operating on background content, prevents Tab from escaping
|
||||||
|
if self.modal && self.popup.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.content
|
self.content
|
||||||
.as_widget_mut()
|
.as_widget_mut()
|
||||||
.operate(content_tree_mut(tree), layout, renderer, operation);
|
.operate(content_tree_mut(tree), layout, renderer, operation);
|
||||||
|
|
@ -172,11 +176,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide cursor from background content when modal popup is active
|
||||||
|
let cursor = if self.modal && self.popup.is_some() {
|
||||||
|
mouse::Cursor::Unavailable
|
||||||
|
} else {
|
||||||
|
cursor_position
|
||||||
|
};
|
||||||
self.content.as_widget_mut().update(
|
self.content.as_widget_mut().update(
|
||||||
&mut tree.children[0],
|
&mut tree.children[0],
|
||||||
event,
|
event,
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor,
|
||||||
renderer,
|
renderer,
|
||||||
clipboard,
|
clipboard,
|
||||||
shell,
|
shell,
|
||||||
|
|
@ -214,13 +224,19 @@ where
|
||||||
cursor_position: mouse::Cursor,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
|
// Hide cursor from background content when a modal popup is active
|
||||||
|
let cursor = if self.modal && self.popup.is_some() {
|
||||||
|
mouse::Cursor::Unavailable
|
||||||
|
} else {
|
||||||
|
cursor_position
|
||||||
|
};
|
||||||
self.content.as_widget().draw(
|
self.content.as_widget().draw(
|
||||||
content_tree(tree),
|
content_tree(tree),
|
||||||
renderer,
|
renderer,
|
||||||
theme,
|
theme,
|
||||||
renderer_style,
|
renderer_style,
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor,
|
||||||
viewport,
|
viewport,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue