mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-12-22 12:28:19 -06:00
actually check event type
This commit is contained in:
parent
03f1d75d3c
commit
59a704d516
|
@ -35,7 +35,7 @@ impl<C: UiSignal + 'static> Interactable<C> {
|
|||
pub fn new(element: Box<dyn UiElement>, event: InteractableEvent, signal: C) -> Self {
|
||||
Self {
|
||||
element,
|
||||
event: InteractableEvent::Click,
|
||||
event,
|
||||
signal: RefCell::new(Some(signal)),
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,12 @@ impl<C: UiSignal + 'static> UiElement for Interactable<C> {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue