Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Diff: Events/EventDispatcher.cpp
- Revision:
- 18:d849f3ada858
- Parent:
- 15:e69fd74d42e4
--- a/Events/EventDispatcher.cpp Sun May 22 16:35:23 2016 +0000 +++ b/Events/EventDispatcher.cpp Sat May 28 14:50:14 2016 +0000 @@ -15,8 +15,35 @@ EventListener* l; _listeners.reset(); while((l=_listeners.next()) != NULL) { - if(l->isEventTarget(e)) { - l->handleEvent(e); - } + l->handleEvent(e); } -} \ No newline at end of file +} + +void EventDispatcher::queueEvent(const Event e) +{ + Event* qe = _mailbox.alloc(); + qe->type = e.type; + qe->target = e.target; + qe->screenX = e.screenX; + qe->screenY = e.screenY; + _mailbox.put(qe); +} + +void EventDispatcher::pumpEvents() +{ + + osEvent oe = _mailbox.get(1); + + if(oe.status == osEventMail) { + + Event* qe = (Event*)oe.value.p; + Event e; + e.target = qe->target; + e.type = qe->type; + e.screenX = qe->screenX; + e.screenY = qe->screenY; + + dispatchEvent(e); + _mailbox.free(qe); + } +}