| OLD | NEW |
| 1 Sky Event Model | 1 Sky Event Model |
| 2 =============== | 2 =============== |
| 3 | 3 |
| 4 ```dart | 4 ```dart |
| 5 SKY MODULE | 5 SKY MODULE |
| 6 <!-- part of sky:core --> | 6 <!-- part of sky:core --> |
| 7 | 7 |
| 8 <script> | 8 <script> |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EventTarget get currentTarget => _currentTarget; | 124 EventTarget get currentTarget => _currentTarget; |
| 125 | 125 |
| 126 bool handled; // precise semantics depend on the event type, but in general, s
et this when you set result | 126 bool handled; // precise semantics depend on the event type, but in general, s
et this when you set result |
| 127 ReturnType result; | 127 ReturnType result; |
| 128 | 128 |
| 129 bool resultIsCompatible(dynamic candidate) => candidate is ReturnType; | 129 bool resultIsCompatible(dynamic candidate) => candidate is ReturnType; |
| 130 | 130 |
| 131 // TODO(ianh): abstract API for doing things at shadow tree boundaries | 131 // TODO(ianh): abstract API for doing things at shadow tree boundaries |
| 132 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events wh
en both sides are in the scope? | 132 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events wh
en both sides are in the scope? |
| 133 // TODO(ianh): do events get retargetted, e.g. focus when leaving a custom ele
ment? | 133 // TODO(ianh): do events get retargetted, e.g. focus when leaving a custom ele
ment? |
| 134 // e.g. sent from inside a shadow tree, when exiting the shadow tree, focus ev
ent should: |
| 135 // - disappear if we're moving from one to another element |
| 136 // - be targetted if it's going to another node in a different scope |
| 134 } | 137 } |
| 135 | 138 |
| 136 class EventTarget { | 139 class EventTarget { |
| 137 EventTarget() : _eventsController = new DispatcherController<Event>(); | 140 EventTarget() : _eventsController = new DispatcherController<Event>(); |
| 138 | 141 |
| 139 Dispatcher get events => _eventsController.dispatcher; | 142 Dispatcher get events => _eventsController.dispatcher; |
| 140 EventTarget parentNode; | 143 EventTarget parentNode; |
| 141 | 144 |
| 142 List<EventTarget> getEventDispatchChain() { | 145 List<EventTarget> getEventDispatchChain() { |
| 143 if (this.parentNode == null) { | 146 if (this.parentNode == null) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return event.result; | 179 return event.result; |
| 177 } | 180 } |
| 178 | 181 |
| 179 void _dispatchEventLocally(Event event) { | 182 void _dispatchEventLocally(Event event) { |
| 180 event._currentTarget = this; | 183 event._currentTarget = this; |
| 181 _eventsController.add(event); | 184 _eventsController.add(event); |
| 182 } | 185 } |
| 183 } | 186 } |
| 184 </script> | 187 </script> |
| 185 ``` | 188 ``` |
| OLD | NEW |