OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 /** | 7 /** |
8 * Base class that supports listening for and dispatching browser events. | 8 * Base class that supports listening for and dispatching browser events. |
9 * | 9 * |
10 * Normally events are accessed via the Stream getter: | 10 * Normally events are accessed via the Stream getter: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 /** | 85 /** |
86 * Base class for all browser objects that support events. | 86 * Base class for all browser objects that support events. |
87 * | 87 * |
88 * Use the [on] property to add, and remove events | 88 * Use the [on] property to add, and remove events |
89 * for compile-time type checks and a more concise API. | 89 * for compile-time type checks and a more concise API. |
90 */ | 90 */ |
91 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 91 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
92 | 92 |
93 $if DARTIUM | |
94 // Default constructor to allow other classes e.g. GlobalEventHandlers to be | |
95 // constructed using _internalWrap when mapping Blink object to Dart class. | |
96 EventTarget(); | |
97 | |
98 $endif | |
99 // Custom element created callback. | 93 // Custom element created callback. |
100 EventTarget._created(); | 94 EventTarget._created(); |
101 | 95 |
102 /** | 96 /** |
103 * This is an ease-of-use accessor for event streams which should only be | 97 * This is an ease-of-use accessor for event streams which should only be |
104 * used when an explicit accessor is not available. | 98 * used when an explicit accessor is not available. |
105 */ | 99 */ |
106 Events get on => new Events(this); | 100 Events get on => new Events(this); |
107 | 101 |
108 void addEventListener(String type, EventListener listener, [bool useCapture])
{ | 102 void addEventListener(String type, EventListener listener, [bool useCapture])
{ |
109 // TODO(leafp): This check is avoid a bug in our dispatch code when | 103 // TODO(leafp): This check is avoid a bug in our dispatch code when |
110 // listener is null. The browser treats this call as a no-op in this | 104 // listener is null. The browser treats this call as a no-op in this |
111 // case, so it's fine to short-circuit it, but we should not have to. | 105 // case, so it's fine to short-circuit it, but we should not have to. |
112 if (listener != null) { | 106 if (listener != null) { |
113 _addEventListener(type, listener, useCapture); | 107 _addEventListener(type, listener, useCapture); |
114 } | 108 } |
115 } | 109 } |
116 | 110 |
117 void removeEventListener(String type, EventListener listener, [bool useCapture
]) { | 111 void removeEventListener(String type, EventListener listener, [bool useCapture
]) { |
118 // TODO(leafp): This check is avoid a bug in our dispatch code when | 112 // TODO(leafp): This check is avoid a bug in our dispatch code when |
119 // listener is null. The browser treats this call as a no-op in this | 113 // listener is null. The browser treats this call as a no-op in this |
120 // case, so it's fine to short-circuit it, but we should not have to. | 114 // case, so it's fine to short-circuit it, but we should not have to. |
121 if (listener != null) { | 115 if (listener != null) { |
122 _removeEventListener(type, listener, useCapture); | 116 _removeEventListener(type, listener, useCapture); |
123 } | 117 } |
124 } | 118 } |
125 | 119 |
126 $!MEMBERS | 120 $!MEMBERS |
127 } | 121 } |
OLD | NEW |