Block hovering behind overlays

This commit is contained in:
Nathan Sobo
2022-05-27 11:54:51 -06:00
parent 5413a97c7e
commit c3baf2748f
5 changed files with 34 additions and 31 deletions
@@ -131,8 +131,7 @@ impl Element for MouseEventHandler {
cx.scene.push_mouse_region(MouseRegion {
view_id: cx.current_view_id(),
tag: self.tag,
region_id: self.id,
discriminant: Some((self.tag, self.id)),
bounds: self.hit_bounds(bounds),
hover: None,
click: self.click_handler.clone(),
+7 -2
View File
@@ -3,8 +3,8 @@ use serde_json::json;
use crate::{
geometry::{rect::RectF, vector::Vector2F},
json::ToJson,
DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
SizeConstraint,
DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, MouseRegion,
PaintContext, SizeConstraint,
};
pub struct Overlay {
@@ -54,6 +54,11 @@ impl Element for Overlay {
let origin = self.abs_position.unwrap_or(bounds.origin());
let visible_bounds = RectF::new(origin, *size);
cx.scene.push_stacking_context(None);
cx.scene.push_mouse_region(MouseRegion {
view_id: cx.current_view_id(),
bounds: visible_bounds,
..Default::default()
});
self.child.paint(origin, visible_bounds, cx);
cx.scene.pop_stacking_context();
}