API Reference 0.7.1rikulo_eventActivateEvent

ActivateEvent class

An event to indicate activation. It is a broadcast event used to notify root views and any listeners that a view or an element is activated. By activated it means the view or the element will become the focal point for users to interact with. For example, it happens when the user clicks on a view or an element (it is done automatically). If the application wants to bring some view to the top, it can broadcast this event too.

broadcaster.sendEvent(new ActivateEvent(activatedView));

Views that acts as popups shall then dismiss themselves when receiving this event. For example,

class Popup extends View {
  Popup() {
    on.activate.add((event) {
      if (event.shallClose(this))
        remove();
    });
  }
}

If the popup is not the root view, it has to register an event listener to broadcaster.

By popup we mean a UI object that is shown up

only in short period of time, and dismissed as soon as the user takes an action. Typical examples include a popup menu and an information bubble.

class ActivateEvent extends ViewEvent {
 final _source;

 /** Constructor.
  * The source parameter is either an instance of [View], a DOM element, or null.
  * If null, it means all pop ups shall be closed.
  */
 ActivateEvent(var source, [String type="activate"]):
 _source = source, super(type) {
 }
 /** Returns the UI object triggers this event.
  * It is either a view or a DOM element.
  */
 get source => _source;

 /** Whether the given view or element shall be closed.
  *
  * + [popup] is either a view or an element.
  */
 bool shallClose(popup) {
   if (source == null)
     return true;

   var srcNode, popNode;
   if (source is View) {
     if (popup is View)
       return !source.isDescendantOf(popup);
     srcNode = source.node;
     popNode = popup;
   } else {
     srcNode = source;
     popNode = popup is View ? popup.node: popup;
   }
   return !DomUtil.isDescendant(srcNode, popNode);
 }
}

Extends

ViewEvent > ActivateEvent

Constructors

new ActivateEvent(source, [String type = "activate"]) #

Constructor. The source parameter is either an instance of View, a DOM element, or null. If null, it means all pop ups shall be closed.

ActivateEvent(var source, [String type="activate"]):
_source = source, super(type) {
}

Properties

View currentTarget #

inherited from ViewEvent

The view that is handling this event currently.

View currentTarget

final bool isPropagationStopped #

inherited from ViewEvent

Returns whether this event's propagation is stopped.

Default: false.

It becomes true if stopPropagation is called, and then all remaining event listeners are ignored.

bool get isPropagationStopped => _propStop;

final source #

Returns the UI object triggers this event. It is either a view or a DOM element.

get source => _source;

View target #

inherited from ViewEvent

Returns the view that this event is targeting to.

View target

final int timeStamp #

inherited from ViewEvent

Returns the time stamp.

int get timeStamp => _stamp;

final String type #

inherited from ViewEvent

Returns the event's type.

String get type => _type;

Methods

void preventDefault() #

inherited from ViewEvent

Prevents the browser's default behavior.

void preventDefault() {
}

bool shallClose(popup) #

Whether the given view or element shall be closed.

  • popup is either a view or an element.
bool shallClose(popup) {
 if (source == null)
   return true;

 var srcNode, popNode;
 if (source is View) {
   if (popup is View)
     return !source.isDescendantOf(popup);
   srcNode = source.node;
   popNode = popup;
 } else {
   srcNode = source;
   popNode = popup is View ? popup.node: popup;
 }
 return !DomUtil.isDescendant(srcNode, popNode);
}

void stopPropagation() #

inherited from ViewEvent

Stops the propagation. Once called, all remaining event listeners, if any, are ignored.

void stopPropagation() {
 _propStop = true;
}

String toString() #

inherited from ViewEvent

Returns a string representation of this object.

docs inherited from Object
@override
String toString() => "ViewEvent($target,$type)";