Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Events/EventDispatcher.cpp@15:e69fd74d42e4, 2016-05-21 (annotated)
- Committer:
- duncanFrance
- Date:
- Sat May 21 18:02:20 2016 +0000
- Revision:
- 15:e69fd74d42e4
- Parent:
- 12:63db16fea709
- Child:
- 18:d849f3ada858
Make attach and detach register/unregister event handlers if needed.; - need to move the event handling into widget so we can attach/detach
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duncanFrance | 0:0a590815d51c | 1 | #include "EventDispatcher.h" |
duncanFrance | 0:0a590815d51c | 2 | |
duncanFrance | 0:0a590815d51c | 3 | EventDispatcher::EventDispatcher() { |
duncanFrance | 0:0a590815d51c | 4 | } |
duncanFrance | 0:0a590815d51c | 5 | |
duncanFrance | 0:0a590815d51c | 6 | void EventDispatcher::attachListener(EventListener* l) { |
duncanFrance | 15:e69fd74d42e4 | 7 | _listeners.appendOnce(l); |
duncanFrance | 0:0a590815d51c | 8 | } |
duncanFrance | 0:0a590815d51c | 9 | |
duncanFrance | 0:0a590815d51c | 10 | void EventDispatcher::detachListener(EventListener* l) { |
duncanFrance | 12:63db16fea709 | 11 | _listeners.remove(l); |
duncanFrance | 0:0a590815d51c | 12 | } |
duncanFrance | 0:0a590815d51c | 13 | |
duncanFrance | 0:0a590815d51c | 14 | void EventDispatcher::dispatchEvent(Event e) { |
duncanFrance | 12:63db16fea709 | 15 | EventListener* l; |
duncanFrance | 12:63db16fea709 | 16 | _listeners.reset(); |
duncanFrance | 12:63db16fea709 | 17 | while((l=_listeners.next()) != NULL) { |
duncanFrance | 12:63db16fea709 | 18 | if(l->isEventTarget(e)) { |
duncanFrance | 12:63db16fea709 | 19 | l->handleEvent(e); |
duncanFrance | 0:0a590815d51c | 20 | } |
duncanFrance | 0:0a590815d51c | 21 | } |
duncanFrance | 0:0a590815d51c | 22 | } |