API Reference 0.5.2dqueryDQueryEvent

DQueryEvent class

A wrapping of browser Event, to attach more information such as custom event data and name space, etc.

class DQueryEvent {
 
 /** The time stamp at which the event occurs. If the event is constructed 
  * from a native DOM [Event], it uses the time stamp of that event;
  * otherwise it uses the current time where this event is constructed. 
  */
 final int timeStamp;
 
 /** The original event, if any. If this [DQueryEvent] was triggered by browser,
  * it will contain an original event; if triggered by API, this property will
  * be null.
  */
 final Event originalEvent;
 
 /** The type of event. If the event is constructed from a native DOM [Event], 
  * it uses the type of that event.
  */
 String get type => _type;
 String _type;
 
 /** Custom event data. If user calls trigger method with data, it will show 
  * up here.
  */
 var data;
 
 /** The delegate target of this event. i.e. The event target on which the 
  * handler is registered.
  */
 EventTarget get delegateTarget => _delegateTarget;
 EventTarget _delegateTarget;
 
 /** The current target of this event when bubbling up.
  */
 EventTarget get currentTarget => _currentTarget;
 EventTarget _currentTarget;
 
 /** The original target of this event. i.e. The real event target where the
  * event occurs.
  */
 EventTarget get target => _target;
 EventTarget _target;
 
 /** The namespace of this event. For example, if the event is triggered by 
  * API with name `click.a.b.c`, it will have type `click` with namespace `a.b.c`
  */
 String get namespace => _namespace;
 String _namespace; // TODO: maybe should be List<String> ?
 
 _HandleObject _handleObj;
 final Event _simulatedEvent; // TODO: check usage
 
 //int _isTrigger; // TODO: check usage
 
 //final Map attributes = new HashMap();
 
 /** Construct a DQueryEvent from a native browser event.
  */
 DQueryEvent.from(Event event, {data}) : 
 this._(event, null, event.type, event.target, event.timeStamp, data);
 
 /** Construct a DQueryEvent with given [type].
  */
 DQueryEvent(String type, {EventTarget target, data}) : 
 this._(null, new Event(type), type, target, _now(), data); // TODO: move target away
 
 DQueryEvent._(this.originalEvent, this._simulatedEvent, this._type, 
     this._target, this.timeStamp, this.data);
 
 /// Return true if [preventDefault] was ever called in this event.
 bool get isDefaultPrevented => _isDefaultPrevented;
 bool _isDefaultPrevented = false;
 
 /// Return true if [stopPropagation] was ever called in this event.
 bool get isPropagationStopped => _isPropagationStopped;
 bool _isPropagationStopped = false;
 
 /// Return true if [stopImmediatePropagation] was ever called in this event.
 bool get isImmediatePropagationStopped => _isImmediatePropagationStopped;
 bool _isImmediatePropagationStopped = false;
 
 /** Prevent the default action of the event being triggered.
  */
 void preventDefault() {
   _isDefaultPrevented = true;
   if (originalEvent != null)
     originalEvent.preventDefault();
 }
 
 /** Prevent the event from bubbling up, and prevent any handlers on parent
  * elements from being called. 
  */
 void stopPropagation() {
   _isPropagationStopped = true;
   if (originalEvent != null)
     originalEvent.stopPropagation();
 }
 
 /** Prevent the event from bubbling up, and prevent any succeeding handlers
  * from being called. 
  */
 void stopImmediatePropagation() {
   _isImmediatePropagationStopped = true;
   stopPropagation();
 }
 
}

Constructors

new DQueryEvent(String type, {EventTarget target, data}) #

Construct a DQueryEvent with given type.

DQueryEvent(String type, {EventTarget target, data}) : 
this._(null, new Event(type), type, target, _now(), data);

new DQueryEvent.from(Event event, {data}) #

Construct a DQueryEvent from a native browser event.

DQueryEvent.from(Event event, {data}) : 
this._(event, null, event.type, event.target, event.timeStamp, data);

Properties

final EventTarget currentTarget #

The current target of this event when bubbling up.

EventTarget get currentTarget => _currentTarget;

var data #

Custom event data. If user calls trigger method with data, it will show up here.

var data

final EventTarget delegateTarget #

The delegate target of this event. i.e. The event target on which the handler is registered.

EventTarget get delegateTarget => _delegateTarget;

final bool isDefaultPrevented #

Return true if preventDefault was ever called in this event.

bool get isDefaultPrevented => _isDefaultPrevented;

final bool isImmediatePropagationStopped #

Return true if stopImmediatePropagation was ever called in this event.

bool get isImmediatePropagationStopped => _isImmediatePropagationStopped;

final bool isPropagationStopped #

Return true if stopPropagation was ever called in this event.

bool get isPropagationStopped => _isPropagationStopped;

final String namespace #

The namespace of this event. For example, if the event is triggered by API with name click.a.b.c, it will have type click with namespace a.b.c

String get namespace => _namespace;

final Event originalEvent #

The original event, if any. If this DQueryEvent was triggered by browser, it will contain an original event; if triggered by API, this property will be null.

final Event originalEvent

final EventTarget target #

The original target of this event. i.e. The real event target where the event occurs.

EventTarget get target => _target;

final int timeStamp #

The time stamp at which the event occurs. If the event is constructed from a native DOM Event, it uses the time stamp of that event; otherwise it uses the current time where this event is constructed.

final int timeStamp

final String type #

The type of event. If the event is constructed from a native DOM Event, it uses the type of that event.

String get type => _type;

Methods

void preventDefault() #

Prevent the default action of the event being triggered.

void preventDefault() {
 _isDefaultPrevented = true;
 if (originalEvent != null)
   originalEvent.preventDefault();
}

void stopImmediatePropagation() #

Prevent the event from bubbling up, and prevent any succeeding handlers from being called.

void stopImmediatePropagation() {
 _isImmediatePropagationStopped = true;
 stopPropagation();
}

void stopPropagation() #

Prevent the event from bubbling up, and prevent any handlers on parent elements from being called.

void stopPropagation() {
 _isPropagationStopped = true;
 if (originalEvent != null)
   originalEvent.stopPropagation();
}