1. /*
  2. * Copyright (c) 2000 World Wide Web Consortium,
  3. * (Massachusetts Institute of Technology, Institut National de
  4. * Recherche en Informatique et en Automatique, Keio University). All
  5. * Rights Reserved. This program is distributed under the W3C's Software
  6. * Intellectual Property License. This program is distributed in the
  7. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. * PURPOSE.
  10. * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  11. */
  12. package org.w3c.dom.events;
  13. /**
  14. * The <code>Event</code> interface is used to provide contextual information
  15. * about an event to the handler processing the event. An object which
  16. * implements the <code>Event</code> interface is generally passed as the
  17. * first parameter to an event handler. More specific context information is
  18. * passed to event handlers by deriving additional interfaces from
  19. * <code>Event</code> which contain information directly relating to the
  20. * type of event they accompany. These derived interfaces are also
  21. * implemented by the object passed to the event listener.
  22. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113'>Document Object Model (DOM) Level 2 Events Specification</a>.
  23. * @since DOM Level 2
  24. */
  25. public interface Event {
  26. // PhaseType
  27. /**
  28. * The current event phase is the capturing phase.
  29. */
  30. public static final short CAPTURING_PHASE = 1;
  31. /**
  32. * The event is currently being evaluated at the target
  33. * <code>EventTarget</code>.
  34. */
  35. public static final short AT_TARGET = 2;
  36. /**
  37. * The current event phase is the bubbling phase.
  38. */
  39. public static final short BUBBLING_PHASE = 3;
  40. /**
  41. * The name of the event (case-insensitive). The name must be an XML name.
  42. */
  43. public String getType();
  44. /**
  45. * Used to indicate the <code>EventTarget</code> to which the event was
  46. * originally dispatched.
  47. */
  48. public EventTarget getTarget();
  49. /**
  50. * Used to indicate the <code>EventTarget</code> whose
  51. * <code>EventListeners</code> are currently being processed. This is
  52. * particularly useful during capturing and bubbling.
  53. */
  54. public EventTarget getCurrentTarget();
  55. /**
  56. * Used to indicate which phase of event flow is currently being
  57. * evaluated.
  58. */
  59. public short getEventPhase();
  60. /**
  61. * Used to indicate whether or not an event is a bubbling event. If the
  62. * event can bubble the value is true, else the value is false.
  63. */
  64. public boolean getBubbles();
  65. /**
  66. * Used to indicate whether or not an event can have its default action
  67. * prevented. If the default action can be prevented the value is true,
  68. * else the value is false.
  69. */
  70. public boolean getCancelable();
  71. /**
  72. * Used to specify the time (in milliseconds relative to the epoch) at
  73. * which the event was created. Due to the fact that some systems may
  74. * not provide this information the value of <code>timeStamp</code> may
  75. * be not available for all events. When not available, a value of 0
  76. * will be returned. Examples of epoch time are the time of the system
  77. * start or 0:0:0 UTC 1st January 1970.
  78. */
  79. public long getTimeStamp();
  80. /**
  81. * The <code>stopPropagation</code> method is used prevent further
  82. * propagation of an event during event flow. If this method is called
  83. * by any <code>EventListener</code> the event will cease propagating
  84. * through the tree. The event will complete dispatch to all listeners
  85. * on the current <code>EventTarget</code> before event flow stops. This
  86. * method may be used during any stage of event flow.
  87. */
  88. public void stopPropagation();
  89. /**
  90. * If an event is cancelable, the <code>preventDefault</code> method is
  91. * used to signify that the event is to be canceled, meaning any default
  92. * action normally taken by the implementation as a result of the event
  93. * will not occur. If, during any stage of event flow, the
  94. * <code>preventDefault</code> method is called the event is canceled.
  95. * Any default action associated with the event will not occur. Calling
  96. * this method for a non-cancelable event has no effect. Once
  97. * <code>preventDefault</code> has been called it will remain in effect
  98. * throughout the remainder of the event's propagation. This method may
  99. * be used during any stage of event flow.
  100. */
  101. public void preventDefault();
  102. /**
  103. * The <code>initEvent</code> method is used to initialize the value of an
  104. * <code>Event</code> created through the <code>DocumentEvent</code>
  105. * interface. This method may only be called before the
  106. * <code>Event</code> has been dispatched via the
  107. * <code>dispatchEvent</code> method, though it may be called multiple
  108. * times during that phase if necessary. If called multiple times the
  109. * final invocation takes precedence. If called from a subclass of
  110. * <code>Event</code> interface only the values specified in the
  111. * <code>initEvent</code> method are modified, all other attributes are
  112. * left unchanged.
  113. * @param eventTypeArgSpecifies the event type. This type may be any
  114. * event type currently defined in this specification or a new event
  115. * type.. The string must be an XML name. Any new event type must not
  116. * begin with any upper, lower, or mixed case version of the string
  117. * "DOM". This prefix is reserved for future DOM event sets. It is
  118. * also strongly recommended that third parties adding their own
  119. * events use their own prefix to avoid confusion and lessen the
  120. * probability of conflicts with other new events.
  121. * @param canBubbleArgSpecifies whether or not the event can bubble.
  122. * @param cancelableArgSpecifies whether or not the event's default
  123. * action can be prevented.
  124. */
  125. public void initEvent(String eventTypeArg,
  126. boolean canBubbleArg,
  127. boolean cancelableArg);
  128. }