Spec-Zone.ru › Dart 2

dart:html

Events class

Base class that supports listening for and dispatching browser events.

Normally events are accessed via the Stream getter:

element.onMouseOver.listen((e) => print('Mouse over!'));

To access bubbling events which are declared on one element, but may bubble up to another element type (common for MediaElement events):

MediaElement.pauseEvent.forTarget(document.body).listen(...);

To useCapture on events:

Element.keyDownEvent.forTarget(element, useCapture: true).listen(...);

Custom events can be declared as:

class DataGenerator {
  static EventStreamProvider<Event> dataEvent =
      new EventStreamProvider('data');
}

Then listeners should access the event with:

DataGenerator.dataEvent.forTarget(element).listen(...);

Custom events can also be accessed as:

element.on['some_event'].listen(...);

This approach is generally discouraged as it loses the event typing and some DOM events may have multiple platform-dependent event names under the covers. By using the standard Stream getters you will get the platform specific event name automatically.

Implementers
  • ElementEvents

Constructors

Events(EventTarget _ptr)

Properties

hashCode → int
read-onlyinherited
The hash code for this object.
runtimeType → Type
read-onlyinherited
A representation of the runtime type of the object.

Methods

noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed.
toString() → String
inherited
A string representation of this object.

Operators

operator ==(Object other) → bool
inherited
The equality operator.
operator [](String type) → Stream<Event>

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-html/Events-class.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API