mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-22 07:08:42 -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 {
|
pub fn new(element: Box<dyn UiElement>, event: InteractableEvent, signal: C) -> Self {
|
||||||
Self {
|
Self {
|
||||||
element,
|
element,
|
||||||
event: InteractableEvent::Click,
|
event,
|
||||||
signal: RefCell::new(Some(signal)),
|
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);
|
let rect = ctx.measure.rect(ctx.layout.position);
|
||||||
|
|
||||||
//XXX: should we do this AFTER normal process call of wrapped element?
|
//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() {
|
if let Some(sig) = self.signal.take() {
|
||||||
ctx.signal.add(sig);
|
ctx.signal.add(sig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue