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); }