git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit6ecddd501f487371925e517b9d349089c68a9a55
parentbbaf0bc8f2
authorLucas Galante <[email protected]>
date2026-07-04 20:59
Implement custom hit_test for Ramp element to correctly capture clicks inside child dropdown popover region

 src/widget/input/ramp.rs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/widget/input/ramp.rs b/src/widget/input/ramp.rs
index e0575cb..2cf096d 100644
--- a/src/widget/input/ramp.rs
+++ b/src/widget/input/ramp.rs
@@ -544,6 +544,23 @@ impl Ramp {
 impl Element for Ramp {
     crate::impl_widget_base!(Ramp);
     
+    fn hit_test(&self, px: f32, py: f32, ctx: &UiContext) -> bool {
+        if ctx.is_coordinate_covered(self as *const Self as *const () as usize, px, py) {
+            return false;
+        }
+        if let Some(pop_rect) = self.popover_rect() {
+            if px >= pop_rect.0 && px <= pop_rect.0 + pop_rect.2 && py >= pop_rect.1 && py <= pop_rect.1 + pop_rect.3 {
+                return true;
+            }
+        }
+        
+        let (x, y, w, h) = self.rect();
+        if w <= 0.0 || h <= 0.0 {
+            return false;
+        }
+        px >= x && px <= x + w && py >= y && py <= y + h
+    }
+    
     fn tick(&mut self, dt: f32, ctx: &mut UiContext) -> bool {
         let mut changed = self.just_changed;
         self.just_changed = false;