Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: sky/sdk/lib/app/view.dart

Issue 1192543004: Create the addEventListener API (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/app/view.dart
diff --git a/sky/sdk/lib/app/view.dart b/sky/sdk/lib/app/view.dart
index d476d5bce36a26304b61f155be3fd3e63bcd4e1d..e4fe302afc9ac6f8901362e0702ef3c944b3b554 100644
--- a/sky/sdk/lib/app/view.dart
+++ b/sky/sdk/lib/app/view.dart
@@ -15,6 +15,8 @@ class PointerState {
PointerState({ this.result, this.lastPosition });
}
+typedef void EventListener(sky.Event event);
+
class AppView {
AppView({ RenderBox root: null, RenderView renderViewOverride }) {
@@ -51,7 +53,9 @@ class AppView {
Function onFrame;
- List<sky.EventListener> eventListeners = new List<sky.EventListener>();
+ final List<EventListener> _eventListeners = new List<EventListener>();
+ void addEventListener(EventListener e) => _eventListeners.add(e);
+ void removeEventListener(EventListener e) => _eventListeners.remove(e);
RenderBox get root => _renderView.child;
void set root(RenderBox value) {
@@ -72,8 +76,8 @@ class AppView {
_renderView.hitTest(result, position: new Point(event.x, event.y));
dispatchEvent(event, result);
} else {
- for (sky.EventListener listener in eventListeners) {
- listener(event);
+ for (EventListener e in _eventListeners) {
+ e(event);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698