From e4bce09c27299d4e4371906af02daa280935bf27 Mon Sep 17 00:00:00 2001 From: fengqi <362254883@qq.com> Date: Sat, 8 Feb 2025 21:37:10 +0800 Subject: [PATCH] 1. Add default styles to several views. --- src/views/container.rs | 4 ++++ src/views/stack.rs | 7 +++++-- src/views/svg.rs | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/views/container.rs b/src/views/container.rs index 328c9185..32a5890f 100644 --- a/src/views/container.rs +++ b/src/views/container.rs @@ -26,6 +26,10 @@ impl View for Container { self.id } + fn view_style(&self) -> Option { + Some(crate::style::Style::new().pointer_events_auto()) + } + fn debug_name(&self) -> std::borrow::Cow<'static, str> { "Container".into() } diff --git a/src/views/stack.rs b/src/views/stack.rs index 644544c2..82380952 100644 --- a/src/views/stack.rs +++ b/src/views/stack.rs @@ -105,8 +105,11 @@ impl View for Stack { } fn view_style(&self) -> Option { - self.direction - .map(|direction| Style::new().flex_direction(direction)) + Some(if let Some(direction) = self.direction { + Style::new().flex_direction(direction).pointer_events_auto() + } else { + Style::new().pointer_events_auto() + }) } fn debug_name(&self) -> std::borrow::Cow<'static, str> { diff --git a/src/views/svg.rs b/src/views/svg.rs index e51b9423..19a153f2 100644 --- a/src/views/svg.rs +++ b/src/views/svg.rs @@ -93,6 +93,10 @@ impl View for Svg { self.id } + fn view_style(&self) -> Option { + Some(crate::style::Style::new().pointer_events_auto()) + } + fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) { self.svg_style.read(cx); }