From 59a704d51614c2470c2d3c8d530c23c616d4d16e Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 13 Mar 2024 14:35:12 +0100 Subject: [PATCH] actually check event type --- hui/src/element/builtin/interactable.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hui/src/element/builtin/interactable.rs b/hui/src/element/builtin/interactable.rs index 1773bbf..1774620 100644 --- a/hui/src/element/builtin/interactable.rs +++ b/hui/src/element/builtin/interactable.rs @@ -35,7 +35,7 @@ impl Interactable { pub fn new(element: Box, event: InteractableEvent, signal: C) -> Self { Self { element, - event: InteractableEvent::Click, + event, signal: RefCell::new(Some(signal)), } } @@ -54,7 +54,12 @@ impl UiElement for Interactable { let rect = ctx.measure.rect(ctx.layout.position); //XXX: should we do this AFTER normal process call of wrapped element? - if ctx.input.check_click(rect) { + let event_happened = match self.event { + InteractableEvent::Click => ctx.input.check_click(rect), + InteractableEvent::Hover => ctx.input.check_hover(rect), + }; + + if event_happened { if let Some(sig) = self.signal.take() { ctx.signal.add(sig); }